[29a9f62] | 1 | #
|
---|
[df4ed85] | 2 | # Copyright (c) 2003-2004 Jakub Jermar
|
---|
[29a9f62] | 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 |
|
---|
[0407636] | 34 | #include <abi/asmtool.h>
|
---|
[4b334fd6] | 35 | #include <libarch/fibril_context.h>
|
---|
[8df9290] | 36 |
|
---|
[b4f1171] | 37 | FUNCTION_BEGIN(__context_save)
|
---|
[a5c78a18] | 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)
|
---|
[a35b458] | 50 |
|
---|
[4b334fd6] | 51 | #ifdef CONFIG_FPU
|
---|
| 52 | mfc1 $t0, $20
|
---|
[a5c78a18] | 53 | sw $t0, __CONTEXT_OFFSET_F20($a0)
|
---|
[a35b458] | 54 |
|
---|
[4b334fd6] | 55 | mfc1 $t0, $21
|
---|
[a5c78a18] | 56 | sw $t0, __CONTEXT_OFFSET_F21($a0)
|
---|
[a35b458] | 57 |
|
---|
[4b334fd6] | 58 | mfc1 $t0, $22
|
---|
[a5c78a18] | 59 | sw $t0, __CONTEXT_OFFSET_F22($a0)
|
---|
[a35b458] | 60 |
|
---|
[4b334fd6] | 61 | mfc1 $t0, $23
|
---|
[a5c78a18] | 62 | sw $t0, __CONTEXT_OFFSET_F23($a0)
|
---|
[a35b458] | 63 |
|
---|
[4b334fd6] | 64 | mfc1 $t0, $24
|
---|
[a5c78a18] | 65 | sw $t0, __CONTEXT_OFFSET_F24($a0)
|
---|
[a35b458] | 66 |
|
---|
[4b334fd6] | 67 | mfc1 $t0, $25
|
---|
[a5c78a18] | 68 | sw $t0, __CONTEXT_OFFSET_F25($a0)
|
---|
[a35b458] | 69 |
|
---|
[4b334fd6] | 70 | mfc1 $t0, $26
|
---|
[a5c78a18] | 71 | sw $t0, __CONTEXT_OFFSET_F26($a0)
|
---|
[a35b458] | 72 |
|
---|
[4b334fd6] | 73 | mfc1 $t0, $27
|
---|
[a5c78a18] | 74 | sw $t0, __CONTEXT_OFFSET_F27($a0)
|
---|
[a35b458] | 75 |
|
---|
[4b334fd6] | 76 | mfc1 $t0, $28
|
---|
[a5c78a18] | 77 | sw $t0, __CONTEXT_OFFSET_F28($a0)
|
---|
[a35b458] | 78 |
|
---|
[4b334fd6] | 79 | mfc1 $t0, $29
|
---|
[a5c78a18] | 80 | sw $t0, __CONTEXT_OFFSET_F29($a0)
|
---|
[a35b458] | 81 |
|
---|
[4b334fd6] | 82 | mfc1 $t0, $30
|
---|
[a5c78a18] | 83 | sw $t0, __CONTEXT_OFFSET_F30($a0)
|
---|
[4b334fd6] | 84 | #endif /* CONFIG_FPU */
|
---|
[a35b458] | 85 |
|
---|
[a5c78a18] | 86 | sw $ra, __CONTEXT_OFFSET_PC($a0)
|
---|
| 87 | sw $sp, __CONTEXT_OFFSET_SP($a0)
|
---|
[a35b458] | 88 |
|
---|
[b4f1171] | 89 | # __context_save returns 0
|
---|
[29a9f62] | 90 | j $ra
|
---|
[a35a3d8] | 91 | li $v0, 0
|
---|
[b4f1171] | 92 | FUNCTION_END(__context_save)
|
---|
[8df9290] | 93 |
|
---|
[b4f1171] | 94 | FUNCTION_BEGIN(__context_restore)
|
---|
[a5c78a18] | 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)
|
---|
[a35b458] | 106 |
|
---|
[4b334fd6] | 107 | #ifdef CONFIG_FPU
|
---|
[a5c78a18] | 108 | lw $t0, __CONTEXT_OFFSET_F20($a0)
|
---|
[4b334fd6] | 109 | mtc1 $t0, $20
|
---|
[a35b458] | 110 |
|
---|
[a5c78a18] | 111 | lw $t0, __CONTEXT_OFFSET_F21($a0)
|
---|
[4b334fd6] | 112 | mtc1 $t0, $21
|
---|
[a35b458] | 113 |
|
---|
[a5c78a18] | 114 | lw $t0, __CONTEXT_OFFSET_F22($a0)
|
---|
[4b334fd6] | 115 | mtc1 $t0, $22
|
---|
[a35b458] | 116 |
|
---|
[a5c78a18] | 117 | lw $t0, __CONTEXT_OFFSET_F23($a0)
|
---|
[4b334fd6] | 118 | mtc1 $t0, $23
|
---|
[a35b458] | 119 |
|
---|
[a5c78a18] | 120 | lw $t0, __CONTEXT_OFFSET_F24($a0)
|
---|
[4b334fd6] | 121 | mtc1 $t0, $24
|
---|
[a35b458] | 122 |
|
---|
[a5c78a18] | 123 | lw $t0, __CONTEXT_OFFSET_F25($a0)
|
---|
[4b334fd6] | 124 | mtc1 $t0, $25
|
---|
[a35b458] | 125 |
|
---|
[a5c78a18] | 126 | lw $t0, __CONTEXT_OFFSET_F26($a0)
|
---|
[4b334fd6] | 127 | mtc1 $t0, $26
|
---|
[a35b458] | 128 |
|
---|
[a5c78a18] | 129 | lw $t0, __CONTEXT_OFFSET_F27($a0)
|
---|
[4b334fd6] | 130 | mtc1 $t0, $27
|
---|
[a35b458] | 131 |
|
---|
[a5c78a18] | 132 | lw $t0, __CONTEXT_OFFSET_F28($a0)
|
---|
[4b334fd6] | 133 | mtc1 $t0, $28
|
---|
[a35b458] | 134 |
|
---|
[a5c78a18] | 135 | lw $t0, __CONTEXT_OFFSET_F29($a0)
|
---|
[4b334fd6] | 136 | mtc1 $t0, $29
|
---|
[a35b458] | 137 |
|
---|
[a5c78a18] | 138 | lw $t0, __CONTEXT_OFFSET_F30($a0)
|
---|
[4b334fd6] | 139 | mtc1 $t0, $30
|
---|
| 140 | #endif /* CONFIG_FPU */
|
---|
[a35b458] | 141 |
|
---|
[a5c78a18] | 142 | lw $ra, __CONTEXT_OFFSET_PC($a0)
|
---|
| 143 | lw $sp, __CONTEXT_OFFSET_SP($a0)
|
---|
[a35b458] | 144 |
|
---|
[df366b5e] | 145 | # Just for the jump into first function,
|
---|
| 146 | # but one instruction should not bother us
|
---|
[8df9290] | 147 | move $t9, $ra
|
---|
[a35b458] | 148 |
|
---|
[b4f1171] | 149 | # __context_restore returns second argument
|
---|
[29a9f62] | 150 | j $ra
|
---|
[a35a3d8] | 151 | move $v0, $a1
|
---|
[b4f1171] | 152 | FUNCTION_END(__context_restore)
|
---|