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 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 12 * ------------------------------------------------- * 13 * |bchai| CR | LR |compl| link| TOC | R14 | R15 | * 14 * ------------------------------------------------- * 15 * ------------------------------------------------- * 16 * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 17 * ------------------------------------------------- * 18 * | R16 | R17 | R18 | R19 | R20 | R21 | R22 | R23 | * 19 * ------------------------------------------------- * 20 * ------------------------------------------------- * 21 * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 22 * ------------------------------------------------- * 23 * | R24 | R25 | R26 | R27 | R28 | R29 | R30 | R31 | * 24 * ------------------------------------------------- * 25 * ------------------------------------------------- * 26 * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 27 * ------------------------------------------------- * 28 * | F14 | F15 | F16 | F17 | * 29 * ------------------------------------------------- * 30 * ------------------------------------------------- * 31 * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 32 * ------------------------------------------------- * 33 * | F18 | F19 | F20 | F21 | * 34 * ------------------------------------------------- * 35 * ------------------------------------------------- * 36 * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * 37 * ------------------------------------------------- * 38 * | F22 | F23 | F24 | F25 | * 39 * ------------------------------------------------- * 40 * ------------------------------------------------- * 41 * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * 42 * ------------------------------------------------- * 43 * | F26 | F27 | F28 | F29 | * 44 * ------------------------------------------------- * 45 * ------------------------------------------------- * 46 * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * 47 * ------------------------------------------------- * 48 * | F30 | F31 | PC |hiddn| fpscr | * 49 * ------------------------------------------------- * 50 * ------------------------------------------------- * 51 * | 256 | 260 | 264 | 268 | 272 | 276 | 280 | 284 | * 52 * ------------------------------------------------- * 53 * |bchai|savCR|savLR|compl| link|svTOC| FCTX| DATA| * 54 * ------------------------------------------------- * 55 * * 56 *******************************************************/ 57 58 .file "jump_ppc32_sysv_xcoff_gas.S" 59 .toc 60 .csect .text[PR], 5 61 .globl jump_fcontext[DS] 62 .globl .jump_fcontext 63 .csect jump_fcontext[DS] 64jump_fcontext: 65 .long .jump_fcontext[PR], TOC[tc0], 0 66 .csect .text[PR], 5 67.jump_fcontext: 68 # reserve space on stack 69 subi 1, 1, 256 70 71 # save CR 72 mfcr 0 73 stw 0, 4(1) 74 # save LR 75 mflr 0 76 stw 0, 8(1) 77 # save LR as PC 78 stw 0, 240(1) 79 # save TOC 80 stw 2, 20(1) 81 82 # Save registers R14 to R31. 83 stw 14, 24(1) 84 stw 15, 28(1) 85 stw 16, 32(1) 86 stw 17, 36(1) 87 stw 18, 40(1) 88 stw 19, 44(1) 89 stw 20, 48(1) 90 stw 21, 52(1) 91 stw 22, 56(1) 92 stw 23, 60(1) 93 stw 24, 64(1) 94 stw 25, 68(1) 95 stw 26, 72(1) 96 stw 27, 76(1) 97 stw 28, 80(1) 98 stw 29, 84(1) 99 stw 30, 88(1) 100 stw 31, 92(1) 101 102 # Save registers F14 to F31 in slots with 8-byte alignment. 103 # 4-byte alignment may stall the pipeline of some processors. 104 # Less than 4 may cause alignment traps. 105 stfd 14, 96(1) 106 stfd 15, 104(1) 107 stfd 16, 112(1) 108 stfd 17, 120(1) 109 stfd 18, 128(1) 110 stfd 19, 136(1) 111 stfd 20, 144(1) 112 stfd 21, 152(1) 113 stfd 22, 160(1) 114 stfd 23, 168(1) 115 stfd 24, 176(1) 116 stfd 25, 184(1) 117 stfd 26, 192(1) 118 stfd 27, 200(1) 119 stfd 28, 208(1) 120 stfd 29, 216(1) 121 stfd 30, 224(1) 122 stfd 31, 232(1) 123 124 # hidden pointer 125 stw 3, 244(1) 126 127 mffs 0 # load FPSCR 128 stfd 0, 248(1) # save FPSCR 129 130 131 # store RSP (pointing to context-data) in R6 132 mr 6, 1 133 134 # restore RSP (pointing to context-data) from R4 135 mr 1, 4 136 137 # restore CR 138 lwz 0, 4(1) 139 mtcr 0 140 # restore LR 141 lwz 0, 8(1) 142 mtlr 0 143 # load PC 144 lwz 0, 240(1) 145 mtctr 0 146 147 # restore TOC 148 lwz 2, 20(1) 149 150 # restore R14 to R31 151 lwz 14, 24(1) 152 lwz 15, 28(1) 153 lwz 16, 32(1) 154 lwz 17, 36(1) 155 lwz 18, 40(1) 156 lwz 19, 44(1) 157 lwz 20, 48(1) 158 lwz 21, 52(1) 159 lwz 22, 56(1) 160 lwz 23, 60(1) 161 lwz 24, 64(1) 162 lwz 25, 68(1) 163 lwz 26, 72(1) 164 lwz 27, 76(1) 165 lwz 28, 80(1) 166 lwz 29, 84(1) 167 lwz 30, 88(1) 168 lwz 31, 92(1) 169 170 # restore F14 to F31 171 lfd 14, 96(1) 172 lfd 15, 104(1) 173 lfd 16, 112(1) 174 lfd 17, 120(1) 175 lfd 18, 128(1) 176 lfd 19, 136(1) 177 lfd 20, 144(1) 178 lfd 21, 152(1) 179 lfd 22, 160(1) 180 lfd 23, 168(1) 181 lfd 24, 176(1) 182 lfd 25, 184(1) 183 lfd 26, 192(1) 184 lfd 27, 200(1) 185 lfd 28, 208(1) 186 lfd 29, 216(1) 187 lfd 30, 224(1) 188 lfd 31, 232(1) 189 190 # hidden pointer 191 lwz 3, 244(1) 192 193 lfd 0, 248(1) # load FPSCR 194 mtfsf 0xff, 0 # restore FPSCR 195 196 # adjust stack 197 addi 1, 1, 256 198 199 # zero in r3 indicates first jump to context-function 200 cmpdi 3, 0 201 beq use_entry_arg 202 203 # return transfer_t 204 stw 6, 0(3) 205 stw 5, 4(3) 206 207 # jump to context 208 bctr 209 210use_entry_arg: 211 # copy transfer_t into transfer_fn arg registers 212 mr 3, 6 213 mr 4, 5 214 215 # jump to context 216 bctr 217