1 /* 2 * Copyright 2019 Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #include <thread.h> 6 #include <arch_thread.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 <tls.h> 14 #include <vm/vm_types.h> 15 #include <vm/VMAddressSpace.h> 16 #include <arch_vm.h> 17 #include <arch/vm_translation_map.h> 18 19 #include <string.h> 20 21 //#define TRACE_ARCH_THREAD 22 #ifdef TRACE_ARCH_THREAD 23 # define TRACE(x) dprintf x 24 #else 25 # define TRACE(x) ; 26 #endif 27 28 29 status_t 30 arch_thread_init(struct kernel_args *args) 31 { 32 return B_OK; 33 } 34 35 36 status_t 37 arch_team_init_team_struct(Team *team, bool kernel) 38 { 39 return B_OK; 40 } 41 42 43 status_t 44 arch_thread_init_thread_struct(Thread *thread) 45 { 46 return B_OK; 47 } 48 49 50 void 51 arch_thread_init_kthread_stack(Thread* thread, void* _stack, void* _stackTop, 52 void (*function)(void*), const void* data) 53 { 54 memset(&thread->arch_info, 0, sizeof(arch_thread)); 55 thread->arch_info.regs[10] = (uint64_t)data; 56 thread->arch_info.regs[11] = (uint64_t)function; 57 thread->arch_info.regs[12] = (uint64_t)_stackTop; 58 } 59 60 61 status_t 62 arch_thread_init_tls(Thread *thread) 63 { 64 return 0; 65 } 66 67 68 extern "C" void _arch_context_swap(arch_thread *from, arch_thread *to); 69 70 71 void 72 arch_thread_context_switch(Thread *from, Thread *to) 73 { 74 _arch_context_swap(&from->arch_info, &to->arch_info); 75 } 76 77 void 78 arch_thread_dump_info(void *info) 79 { 80 } 81 82 83 status_t 84 arch_thread_enter_userspace(Thread *thread, addr_t entry, 85 void *arg1, void *arg2) 86 { 87 return B_ERROR; 88 } 89 90 91 bool 92 arch_on_signal_stack(Thread *thread) 93 { 94 return false; 95 } 96 97 98 status_t 99 arch_setup_signal_frame(Thread *thread, struct sigaction *sa, 100 struct signal_frame_data *signalFrameData) 101 { 102 return B_ERROR; 103 } 104 105 106 int64 107 arch_restore_signal_frame(struct signal_frame_data* signalFrameData) 108 { 109 return 0; 110 } 111 112 113 void 114 arch_check_syscall_restart(Thread *thread) 115 { 116 } 117 118 119 void 120 arch_store_fork_frame(struct arch_fork_arg *arg) 121 { 122 } 123 124 125 void 126 arch_restore_fork_frame(struct arch_fork_arg *arg) 127 { 128 } 129