1/******************************************************* 2 * * 3 * ------------------------------------------------- * 4 * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 5 * ------------------------------------------------- * 6 * | 0 | 8 | 16 | 24 | * 7 * ------------------------------------------------- * 8 * | FS0 | FS1 | FS2 | FS3 | * 9 * ------------------------------------------------- * 10 * ------------------------------------------------- * 11 * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 12 * ------------------------------------------------- * 13 * | 32 | 40 | 48 | 56 | * 14 * ------------------------------------------------- * 15 * | FS4 | FS5 | FS6 | FS7 | * 16 * ------------------------------------------------- * 17 * ------------------------------------------------- * 18 * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 19 * ------------------------------------------------- * 20 * | 64 | 72 | 80 | 88 | * 21 * ------------------------------------------------- * 22 * | S0 | S1 | S2 | S3 | * 23 * ------------------------------------------------- * 24 * ------------------------------------------------- * 25 * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 26 * ------------------------------------------------- * 27 * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 28 * ------------------------------------------------- * 29 * | S4 | S5 | S6 | S7 | * 30 * ------------------------------------------------- * 31 * ------------------------------------------------- * 32 * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 33 * ------------------------------------------------- * 34 * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 35 * ------------------------------------------------- * 36 * | S8 | FP | RA | PC | * 37 * ------------------------------------------------- * 38 * * 39 * *****************************************************/ 40 41.file "make_loongarch64_sysv_elf_gas.S" 42.text 43.globl make_fcontext 44.align 2 45.type make_fcontext,@function 46make_fcontext: 47 # shift address in A0 to lower 16 byte boundary 48 bstrins.d $a0, $zero, 3, 0 49 50 # reserve space for context-data on context-stack 51 addi.d $a0, $a0, -160 52 53 # third arg of make_fcontext() == address of context-function 54 st.d $a2, $a0, 152 55 56 # save address of finish as return-address for context-function 57 # will be entered after context-function returns 58 la.local $a4, finish 59 st.d $a4, $a0, 144 60 61 # return pointer to context-data 62 jr $ra 63 64finish: 65 # exit code is zero 66 li.d $a0, 0 67 # call _exit(0) 68 b %plt(_exit) 69 70.size make_fcontext, .-make_fcontext 71/* Mark that we don't need executable stack. */ 72.section .note.GNU-stack,"",%progbits 73