1 /* Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk 2 * Distributed under the terms of the MIT License. 3 */ 4 5 6 #include <string.h> 7 8 #include <arch_cpu.h> 9 #include <arch/thread.h> 10 #include <boot/stage2.h> 11 #include <kernel.h> 12 #include <thread.h> 13 #include <vm/vm_types.h> 14 15 16 status_t 17 arch_thread_init(struct kernel_args *args) 18 { 19 // Initialize the static initial arch_thread state (sInitialState). 20 // Currently nothing to do, i.e. zero initialized is just fine. 21 22 return B_OK; 23 } 24 25 26 status_t 27 arch_team_init_team_struct(Team *team, bool kernel) 28 { 29 // Nothing to do. The structure is empty. 30 return B_OK; 31 } 32 33 34 status_t 35 arch_thread_init_thread_struct(Thread *thread) 36 { 37 // set up an initial state (stack & fpu) 38 //memcpy(&thread->arch_info, &sInitialState, sizeof(struct arch_thread)); 39 40 return B_OK; 41 } 42 43 44 void 45 arch_thread_init_kthread_stack(Thread* thread, void* _stack, void* _stackTop, 46 void (*function)(void*), const void* data) 47 { 48 #warning RISCV64: Implement thread init kthread 49 panic("arch_thread_init_kthread_stack(): Implement me!"); 50 } 51 52 53 status_t 54 arch_thread_init_tls(Thread *thread) 55 { 56 // TODO: Implement! 57 return B_OK; 58 } 59 60 61 void 62 arch_thread_context_switch(Thread *from, Thread *to) 63 { 64 } 65 66 67 void 68 arch_thread_dump_info(void *info) 69 { 70 } 71 72 73 status_t 74 arch_thread_enter_userspace(Thread *thread, addr_t entry, void *arg1, void *arg2) 75 { 76 panic("arch_thread_enter_uspace(): not yet implemented\n"); 77 return B_ERROR; 78 } 79 80 81 bool 82 arch_on_signal_stack(Thread *thread) 83 { 84 return false; 85 } 86 87 88 status_t 89 arch_setup_signal_frame(Thread *thread, struct sigaction *sa, 90 struct signal_frame_data *signalFrameData) 91 { 92 return B_ERROR; 93 } 94 95 96 int64 97 arch_restore_signal_frame(struct signal_frame_data* signalFrameData) 98 { 99 return 0; 100 } 101 102 103 void 104 arch_check_syscall_restart(Thread *thread) 105 { 106 } 107 108 109 /** Saves everything needed to restore the frame in the child fork in the 110 * arch_fork_arg structure to be passed to arch_restore_fork_frame(). 111 * Also makes sure to return the right value. 112 */ 113 114 void 115 arch_store_fork_frame(struct arch_fork_arg *arg) 116 { 117 } 118 119 120 /** Restores the frame from a forked team as specified by the provided 121 * arch_fork_arg structure. 122 * Needs to be called from within the child team, ie. instead of 123 * arch_thread_enter_uspace() as thread "starter". 124 * This function does not return to the caller, but will enter userland 125 * in the child team at the same position where the parent team left of. 126 */ 127 128 void 129 arch_restore_fork_frame(struct arch_fork_arg *arg) 130 { 131 } 132 133