|
1 | 1 | /* |
2 | 2 | Copyright Edward Nevill + Oliver Kowalke 2015 |
| 3 | + Copyright Adrian Astley 2025. |
3 | 4 | Distributed under the Boost Software License, Version 1.0. |
4 | 5 | (See accompanying file LICENSE_1_0.txt or copy at |
5 | 6 | http://www.boost.org/LICENSE_1_0.txt) |
|
42 | 43 | * | x27 | x28 | FP | LR | * |
43 | 44 | * ------------------------------------------------- * |
44 | 45 | * ------------------------------------------------- * |
45 | | - * | 40 | 41 | 42 | 43 | | | * |
| 46 | + * | 40 | 41 | 42 | 43 | 444| 45 | 46 | 47 | * |
46 | 47 | * ------------------------------------------------- * |
47 | | - * | 0xa0| 0xa4| 0xa8| 0xac| | | * |
| 48 | + * | 0xa0| 0xa4| 0xa8| 0xac| 0xb0| 0xb4| 0xb8| 0xbc| * |
48 | 49 | * ------------------------------------------------- * |
49 | 50 | * | PC | align | | | * |
50 | 51 | * ------------------------------------------------- * |
|
55 | 56 | .globl _jump_fcontext |
56 | 57 | .balign 16 |
57 | 58 | _jump_fcontext: |
58 | | - ; prepare stack for GP + FPU |
| 59 | + # prepare stack for GP + FPU |
59 | 60 | sub sp, sp, #0xb0 |
60 | 61 |
|
61 | | - ; save d8 - d15 |
| 62 | + # save d8 - d15 |
62 | 63 | stp d8, d9, [sp, #0x00] |
63 | 64 | stp d10, d11, [sp, #0x10] |
64 | 65 | stp d12, d13, [sp, #0x20] |
65 | 66 | stp d14, d15, [sp, #0x30] |
66 | 67 |
|
67 | | - ; save x19-x30 |
| 68 | + # save x19-x30 |
68 | 69 | stp x19, x20, [sp, #0x40] |
69 | 70 | stp x21, x22, [sp, #0x50] |
70 | 71 | stp x23, x24, [sp, #0x60] |
71 | 72 | stp x25, x26, [sp, #0x70] |
72 | 73 | stp x27, x28, [sp, #0x80] |
73 | | - stp fp, lr, [sp, #0x90] |
| 74 | + stp x29, x30, [sp, #0x90] |
74 | 75 |
|
75 | | - ; save LR as PC |
76 | | - str lr, [sp, #0xa0] |
| 76 | + # save LR as PC |
| 77 | + str x30, [sp, #0xa0] |
77 | 78 |
|
78 | | - ; store RSP (pointing to context-data) in X0 |
79 | | - mov x4, sp |
| 79 | + # store RSP (pointing to context-data) at address pointed at by X0 |
| 80 | + # STR doesn't allow us to use sp as the base register, so we have to mov it to x4 first |
| 81 | + mov x4, sp |
| 82 | + str x4, [x0, 0] |
80 | 83 |
|
81 | | - ; restore RSP (pointing to context-data) from X1 |
82 | | - mov sp, x0 |
| 84 | + # restore RSP (pointing to context-data) from X1 |
| 85 | + mov sp, x1 |
83 | 86 |
|
84 | | - ; load d8 - d15 |
| 87 | + # load d8 - d15 |
85 | 88 | ldp d8, d9, [sp, #0x00] |
86 | 89 | ldp d10, d11, [sp, #0x10] |
87 | 90 | ldp d12, d13, [sp, #0x20] |
88 | 91 | ldp d14, d15, [sp, #0x30] |
89 | 92 |
|
90 | | - ; load x19-x30 |
| 93 | + # load x19-x30 |
91 | 94 | ldp x19, x20, [sp, #0x40] |
92 | 95 | ldp x21, x22, [sp, #0x50] |
93 | 96 | ldp x23, x24, [sp, #0x60] |
94 | 97 | ldp x25, x26, [sp, #0x70] |
95 | 98 | ldp x27, x28, [sp, #0x80] |
96 | | - ldp fp, lr, [sp, #0x90] |
| 99 | + ldp x29, x30, [sp, #0x90] |
97 | 100 |
|
98 | | - ; return transfer_t from jump |
99 | | - ; pass transfer_t as first arg in context function |
100 | | - ; X0 == FCTX, X1 == DATA |
101 | | - mov x0, x4 |
| 101 | + # pass data (third arg passed to jump_fcontext) as first arg passed to context function |
| 102 | + mov x0, x2 |
102 | 103 |
|
103 | | - ; load pc |
| 104 | + # load pc |
104 | 105 | ldr x4, [sp, #0xa0] |
105 | 106 |
|
106 | | - ; restore stack from GP + FPU |
| 107 | + # restore stack from GP + FP |
107 | 108 | add sp, sp, #0xb0 |
108 | 109 |
|
109 | 110 | ret x4 |
0 commit comments