source: mainline/uspace/lib/c/arch/mips32/src/fibril.S@ 615e83d

Last change on this file since 615e83d was 615e83d, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 8 years ago

Turn context_save/context_restore into standard setjmp/longjmp.

  • Property mode set to 100644
File size: 3.7 KB
RevLine 
[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
[615e83d]37FUNCTION_BEGIN(setjmp)
[4b334fd6]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)
[a35b458]48
[4b334fd6]49 sw $k1, CONTEXT_OFFSET_TLS($a0)
[a35b458]50
[4b334fd6]51#ifdef CONFIG_FPU
52 mfc1 $t0, $20
53 sw $t0, CONTEXT_OFFSET_F20($a0)
[a35b458]54
[4b334fd6]55 mfc1 $t0, $21
56 sw $t0, CONTEXT_OFFSET_F21($a0)
[a35b458]57
[4b334fd6]58 mfc1 $t0, $22
59 sw $t0, CONTEXT_OFFSET_F22($a0)
[a35b458]60
[4b334fd6]61 mfc1 $t0, $23
62 sw $t0, CONTEXT_OFFSET_F23($a0)
[a35b458]63
[4b334fd6]64 mfc1 $t0, $24
65 sw $t0, CONTEXT_OFFSET_F24($a0)
[a35b458]66
[4b334fd6]67 mfc1 $t0, $25
68 sw $t0, CONTEXT_OFFSET_F25($a0)
[a35b458]69
[4b334fd6]70 mfc1 $t0, $26
71 sw $t0, CONTEXT_OFFSET_F26($a0)
[a35b458]72
[4b334fd6]73 mfc1 $t0, $27
74 sw $t0, CONTEXT_OFFSET_F27($a0)
[a35b458]75
[4b334fd6]76 mfc1 $t0, $28
77 sw $t0, CONTEXT_OFFSET_F28($a0)
[a35b458]78
[4b334fd6]79 mfc1 $t0, $29
80 sw $t0, CONTEXT_OFFSET_F29($a0)
[a35b458]81
[4b334fd6]82 mfc1 $t0, $30
83 sw $t0, CONTEXT_OFFSET_F30($a0)
84#endif /* CONFIG_FPU */
[a35b458]85
[4b334fd6]86 sw $ra, CONTEXT_OFFSET_PC($a0)
87 sw $sp, CONTEXT_OFFSET_SP($a0)
[a35b458]88
[615e83d]89 # setjmp returns 0
[29a9f62]90 j $ra
[615e83d]91 li $v0, 0
92FUNCTION_END(setjmp)
[8df9290]93
[615e83d]94FUNCTION_BEGIN(__longjmp)
[4b334fd6]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
108 lw $t0, CONTEXT_OFFSET_F20($a0)
109 mtc1 $t0, $20
[a35b458]110
[4b334fd6]111 lw $t0, CONTEXT_OFFSET_F21($a0)
112 mtc1 $t0, $21
[a35b458]113
[4b334fd6]114 lw $t0, CONTEXT_OFFSET_F22($a0)
115 mtc1 $t0, $22
[a35b458]116
[4b334fd6]117 lw $t0, CONTEXT_OFFSET_F23($a0)
118 mtc1 $t0, $23
[a35b458]119
[4b334fd6]120 lw $t0, CONTEXT_OFFSET_F24($a0)
121 mtc1 $t0, $24
[a35b458]122
[4b334fd6]123 lw $t0, CONTEXT_OFFSET_F25($a0)
124 mtc1 $t0, $25
[a35b458]125
[4b334fd6]126 lw $t0, CONTEXT_OFFSET_F26($a0)
127 mtc1 $t0, $26
[a35b458]128
[4b334fd6]129 lw $t0, CONTEXT_OFFSET_F27($a0)
130 mtc1 $t0, $27
[a35b458]131
[4b334fd6]132 lw $t0, CONTEXT_OFFSET_F28($a0)
133 mtc1 $t0, $28
[a35b458]134
[4b334fd6]135 lw $t0, CONTEXT_OFFSET_F29($a0)
136 mtc1 $t0, $29
[a35b458]137
[4b334fd6]138 lw $t0, CONTEXT_OFFSET_F30($a0)
139 mtc1 $t0, $30
140#endif /* CONFIG_FPU */
[a35b458]141
[4b334fd6]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
[615e83d]149 # __longjmp returns second argument
[29a9f62]150 j $ra
[615e83d]151 move $v0, $a1
152FUNCTION_END(__longjmp)
Note: See TracBrowser for help on using the repository browser.