• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2            Copyright Oliver Kowalke 2009.
3   Distributed under the Boost Software License, Version 1.0.
4      (See accompanying file LICENSE_1_0.txt or copy at
5          http://www.boost.org/LICENSE_1_0.txt)
6*/
7
8/*******************************************************
9 *                                                     *
10 *  -------------------------------------------------  *
11 *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
12 *  -------------------------------------------------  *
13 *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
14 *  -------------------------------------------------  *
15 *  |    F20    |    F22    |    F24    |    F26    |  *
16 *  -------------------------------------------------  *
17 *  -------------------------------------------------  *
18 *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
19 *  -------------------------------------------------  *
20 *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
21 *  -------------------------------------------------  *
22 *  |    F28    |    F30    |  S0 |  S1 |  S2 |  S3 |  *
23 *  -------------------------------------------------  *
24 *  -------------------------------------------------  *
25 *  |  16 |  17 |  18 |  19 |  20 |  21 |  22 |  23 |  *
26 *  -------------------------------------------------  *
27 *  |  64 |  68 |  72 |  76 |  80 |  84 |  88 |  92 |  *
28 *  -------------------------------------------------  *
29 *  |  S4 |  S5 |  S6 |  S7 |  FP |hiddn|  RA |  PC |  *
30 *  -------------------------------------------------  *
31 *  -------------------------------------------------  *
32 *  |  24 |  25 |  26 |  27 |  28 |  29 |  30 |  31 |  *
33 *  -------------------------------------------------  *
34 *  |  96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 |  *
35 *  -------------------------------------------------  *
36 *  |       ABI ARGS        |  GP | FCTX| DATA|     |  *
37 *  -------------------------------------------------  *
38 *                                                     *
39 * *****************************************************/
40
41.file "ontop_mips32_o32_elf_gas.S"
42.text
43.globl ontop_fcontext
44.align 2
45.type ontop_fcontext,@function
46.ent ontop_fcontext
47ontop_fcontext:
48    # reserve space on stack
49    addiu $sp, $sp, -96
50
51    sw  $s0, 48($sp)  # save S0
52    sw  $s1, 52($sp)  # save S1
53    sw  $s2, 56($sp)  # save S2
54    sw  $s3, 60($sp)  # save S3
55    sw  $s4, 64($sp)  # save S4
56    sw  $s5, 68($sp)  # save S5
57    sw  $s6, 72($sp)  # save S6
58    sw  $s7, 76($sp)  # save S7
59    sw  $fp, 80($sp)  # save FP
60    sw  $a0, 84($sp)  # save hidden, address of returned transfer_t
61    sw  $ra, 88($sp)  # save RA
62    sw  $ra, 92($sp)  # save RA as PC
63
64#if defined(__mips_hard_float)
65    s.d  $f20, ($sp)  # save F20
66    s.d  $f22, 8($sp)  # save F22
67    s.d  $f24, 16($sp)  # save F24
68    s.d  $f26, 24($sp)  # save F26
69    s.d  $f28, 32($sp)  # save F28
70    s.d  $f30, 40($sp)  # save F30
71#endif
72
73    # store SP (pointing to context-data) in A0
74    move  $a0, $sp
75
76    # restore SP (pointing to context-data) from A1
77    move  $sp, $a1
78
79#if defined(__mips_hard_float)
80    l.d  $f20, ($sp)  # restore F20
81    l.d  $f22, 8($sp)  # restore F22
82    l.d  $f24, 16($sp)  # restore F24
83    l.d  $f26, 24($sp)  # restore F26
84    l.d  $f28, 32($sp)  # restore F28
85    l.d  $f30, 40($sp)  # restore F30
86#endif
87
88    lw  $s0, 48($sp)  # restore S0
89    lw  $s1, 52($sp)  # restore S1
90    lw  $s2, 56($sp)  # restore S2
91    lw  $s3, 60($sp)  # restore S3
92    lw  $s4, 64($sp)  # restore S4
93    lw  $s5, 68($sp)  # restore S5
94    lw  $s6, 72($sp)  # restore S6
95    lw  $s7, 76($sp)  # restore S7
96    lw  $fp, 80($sp)  # restore FP
97    lw  $v0, 84($sp)  # restore hidden, address of returned transfer_t
98    lw  $ra, 88($sp)  # restore RA
99
100    # load PC
101    move $t9, $a3
102
103    # adjust stack
104    addiu $sp, $sp, 96
105
106    # return transfer_t from jump
107    sw  $a0, ($v0)  # fctx of transfer_t
108    sw  $a2, 4($v0) # data of transfer_t
109    # pass transfer_t as first arg in context function
110    # A0 == hidden, A1 == fctx, A2 == data
111    move  $a1, $a0
112    move  $a0, $v0
113
114    # jump to context
115    jr  $t9
116.end ontop_fcontext
117.size ontop_fcontext, .-ontop_fcontext
118
119/* Mark that we don't need executable stack.  */
120.section .note.GNU-stack,"",%progbits
121