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