Rev 1113 | Rev 1660 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1113 | Rev 1123 | ||
---|---|---|---|
1 | # |
1 | # |
2 | # Copyright (C) 2003-2004 Jakub Jermar |
2 | # Copyright (C) 2003-2004 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: |
8 | # |
8 | # |
9 | # - Redistributions of source code must retain the above copyright |
9 | # - Redistributions of source code must retain the above copyright |
10 | # notice, this list of conditions and the following disclaimer. |
10 | # notice, this list of conditions and the following disclaimer. |
11 | # - Redistributions in binary form must reproduce the above copyright |
11 | # - Redistributions in binary form must reproduce the above copyright |
12 | # notice, this list of conditions and the following disclaimer in the |
12 | # notice, this list of conditions and the following disclaimer in the |
13 | # documentation and/or other materials provided with the distribution. |
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 |
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. |
15 | # derived from this software without specific prior written permission. |
16 | # |
16 | # |
17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
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 |
18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 |
23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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 | .text |
29 | .text |
30 | 30 | ||
31 | .set noat |
31 | .set noat |
32 | .set noreorder |
32 | .set noreorder |
33 | .set nomacro |
- | |
34 | 33 | ||
35 | 34 | ||
36 | #include <arch/asm/regname.h> |
35 | #include <arch/asm/regname.h> |
37 | #include <libarch/context_offset.h> |
36 | #include <libarch/context_offset.h> |
38 | 37 | ||
39 | .global context_save |
38 | .global context_save |
40 | .global context_restore |
39 | .global context_restore |
41 | 40 | ||
42 | .macro CONTEXT_STORE r |
41 | .macro CONTEXT_STORE r |
43 | sw $s0,OFFSET_S0(\r) |
42 | sw $s0,OFFSET_S0(\r) |
44 | sw $s1,OFFSET_S1(\r) |
43 | sw $s1,OFFSET_S1(\r) |
45 | sw $s2,OFFSET_S2(\r) |
44 | sw $s2,OFFSET_S2(\r) |
46 | sw $s3,OFFSET_S3(\r) |
45 | sw $s3,OFFSET_S3(\r) |
47 | sw $s4,OFFSET_S4(\r) |
46 | sw $s4,OFFSET_S4(\r) |
48 | sw $s5,OFFSET_S5(\r) |
47 | sw $s5,OFFSET_S5(\r) |
49 | sw $s6,OFFSET_S6(\r) |
48 | sw $s6,OFFSET_S6(\r) |
50 | sw $s7,OFFSET_S7(\r) |
49 | sw $s7,OFFSET_S7(\r) |
51 | sw $s8,OFFSET_S8(\r) |
50 | sw $s8,OFFSET_S8(\r) |
52 | sw $gp,OFFSET_GP(\r) |
51 | sw $gp,OFFSET_GP(\r) |
53 | sw $k1,OFFSET_TLS(\r) |
52 | sw $k1,OFFSET_TLS(\r) |
54 | 53 | ||
55 | sw $ra,OFFSET_PC(\r) |
54 | sw $ra,OFFSET_PC(\r) |
56 | sw $sp,OFFSET_SP(\r) |
55 | sw $sp,OFFSET_SP(\r) |
57 | .endm |
56 | .endm |
58 | 57 | ||
59 | .macro CONTEXT_LOAD r |
58 | .macro CONTEXT_LOAD r |
60 | lw $s0,OFFSET_S0(\r) |
59 | lw $s0,OFFSET_S0(\r) |
61 | lw $s1,OFFSET_S1(\r) |
60 | lw $s1,OFFSET_S1(\r) |
62 | lw $s2,OFFSET_S2(\r) |
61 | lw $s2,OFFSET_S2(\r) |
63 | lw $s3,OFFSET_S3(\r) |
62 | lw $s3,OFFSET_S3(\r) |
64 | lw $s4,OFFSET_S4(\r) |
63 | lw $s4,OFFSET_S4(\r) |
65 | lw $s5,OFFSET_S5(\r) |
64 | lw $s5,OFFSET_S5(\r) |
66 | lw $s6,OFFSET_S6(\r) |
65 | lw $s6,OFFSET_S6(\r) |
67 | lw $s7,OFFSET_S7(\r) |
66 | lw $s7,OFFSET_S7(\r) |
68 | lw $s8,OFFSET_S8(\r) |
67 | lw $s8,OFFSET_S8(\r) |
69 | lw $gp,OFFSET_GP(\r) |
68 | lw $gp,OFFSET_GP(\r) |
70 | lw $k1,OFFSET_TLS(\r) |
69 | lw $k1,OFFSET_TLS(\r) |
71 | 70 | ||
72 | lw $ra,OFFSET_PC(\r) |
71 | lw $ra,OFFSET_PC(\r) |
73 | lw $sp,OFFSET_SP(\r) |
72 | lw $sp,OFFSET_SP(\r) |
74 | .endm |
73 | .endm |
75 | 74 | ||
76 | context_save: |
75 | context_save: |
77 | CONTEXT_STORE $a0 |
76 | CONTEXT_STORE $a0 |
78 | 77 | ||
79 | # context_save returns 1 |
78 | # context_save returns 1 |
80 | j $ra |
79 | j $ra |
81 | li $v0, 1 |
80 | li $v0, 1 |
82 | 81 | ||
83 | context_restore: |
82 | context_restore: |
84 | CONTEXT_LOAD $a0 |
83 | CONTEXT_LOAD $a0 |
85 | 84 | ||
- | 85 | # Just for the jump into first function, but one instruction |
|
- | 86 | # should not bother us |
|
- | 87 | move $t9, $ra |
|
86 | # context_restore returns 0 |
88 | # context_restore returns 0 |
87 | j $ra |
89 | j $ra |
88 | xor $v0, $v0 |
90 | xor $v0, $v0 |
- | 91 | ||
89 | 92 |