1/* 2 * Copyright 2019-2021, Haiku, Inc. All Rights Reserved 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7#include <asm_defs.h> 8#include "syscall_numbers.h" 9 10 11.text 12 13 14FUNCTION(MSyscall): 15 ecall 16 ret 17FUNCTION_END(MSyscall) 18 19 20FUNCTION(arch_context_switch): 21# save `from` context 22 sd ra, 0*8(a0) 23 sd s0, 1*8(a0) 24 sd s1, 2*8(a0) 25 sd s2, 3*8(a0) 26 sd s3, 4*8(a0) 27 sd s4, 5*8(a0) 28 sd s5, 6*8(a0) 29 sd s6, 7*8(a0) 30 sd s7, 8*8(a0) 31 sd s8, 9*8(a0) 32 sd s9, 10*8(a0) 33 sd s10, 11*8(a0) 34 sd s11, 12*8(a0) 35 sd sp, 13*8(a0) 36 37# load `to` context 38 ld ra, 0*8(a1) 39 ld s0, 1*8(a1) 40 ld s1, 2*8(a1) 41 ld s2, 3*8(a1) 42 ld s3, 4*8(a1) 43 ld s4, 5*8(a1) 44 ld s5, 6*8(a1) 45 ld s6, 7*8(a1) 46 ld s7, 8*8(a1) 47 ld s8, 9*8(a1) 48 ld s9, 10*8(a1) 49 ld s10, 11*8(a1) 50 ld s11, 12*8(a1) 51 ld sp, 13*8(a1) 52 53 ret 54FUNCTION_END(arch_context_switch) 55 56 57FUNCTION(save_fpu): 58 fsd f0, 0*8(a0) 59 fsd f1, 1*8(a0) 60 fsd f2, 2*8(a0) 61 fsd f3, 3*8(a0) 62 fsd f4, 4*8(a0) 63 fsd f5, 5*8(a0) 64 fsd f6, 6*8(a0) 65 fsd f7, 7*8(a0) 66 fsd f8, 8*8(a0) 67 fsd f9, 9*8(a0) 68 fsd f10, 10*8(a0) 69 fsd f11, 11*8(a0) 70 fsd f12, 12*8(a0) 71 fsd f13, 13*8(a0) 72 fsd f14, 14*8(a0) 73 fsd f15, 15*8(a0) 74 fsd f16, 16*8(a0) 75 fsd f17, 17*8(a0) 76 fsd f18, 18*8(a0) 77 fsd f19, 19*8(a0) 78 fsd f20, 20*8(a0) 79 fsd f21, 21*8(a0) 80 fsd f22, 22*8(a0) 81 fsd f23, 23*8(a0) 82 fsd f24, 24*8(a0) 83 fsd f25, 25*8(a0) 84 fsd f26, 26*8(a0) 85 fsd f27, 27*8(a0) 86 fsd f28, 28*8(a0) 87 fsd f29, 29*8(a0) 88 fsd f30, 30*8(a0) 89 fsd f31, 31*8(a0) 90 frcsr t0 91 sd t0, 32*8(a0) 92 93 ret 94FUNCTION_END(save_fpu) 95 96 97FUNCTION(restore_fpu): 98 fld f0, 0*8(a0) 99 fld f1, 1*8(a0) 100 fld f2, 2*8(a0) 101 fld f3, 3*8(a0) 102 fld f4, 4*8(a0) 103 fld f5, 5*8(a0) 104 fld f6, 6*8(a0) 105 fld f7, 7*8(a0) 106 fld f8, 8*8(a0) 107 fld f9, 9*8(a0) 108 fld f10, 10*8(a0) 109 fld f11, 11*8(a0) 110 fld f12, 12*8(a0) 111 fld f13, 13*8(a0) 112 fld f14, 14*8(a0) 113 fld f15, 15*8(a0) 114 fld f16, 16*8(a0) 115 fld f17, 17*8(a0) 116 fld f18, 18*8(a0) 117 fld f19, 19*8(a0) 118 fld f20, 20*8(a0) 119 fld f21, 21*8(a0) 120 fld f22, 22*8(a0) 121 fld f23, 23*8(a0) 122 fld f24, 24*8(a0) 123 fld f25, 25*8(a0) 124 fld f26, 26*8(a0) 125 fld f27, 27*8(a0) 126 fld f28, 28*8(a0) 127 fld f29, 29*8(a0) 128 fld f30, 30*8(a0) 129 fld f31, 31*8(a0) 130 ld t0, 32*8(a0) 131 fscsr t0 132 133 ret 134FUNCTION_END(restore_fpu) 135 136 137FUNCTION(arch_thread_entry): 138 mv a0, s2 139 jr s1 140FUNCTION_END(arch_thread_entry) 141 142 143FUNCTION(arch_load_user_iframe): 144 mv fp, a0 145 mv sp, a1 146 tail SVecURet 147FUNCTION_END(arch_load_user_iframe) 148 149 150FUNCTION(arch_user_thread_exit): 151 li t0, SYSCALL_EXIT_THREAD 152 ecall 153 ret 154FUNCTION_END(arch_user_thread_exit) 155