1 /* 2 * Copyright 2003-2010, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Axel Dörfler <axeld@pinc-software.de> 7 * Ingo Weinhold <bonefish@cs.tu-berlin.de> 8 * François Revol <revol@free.fr> 9 * 10 * Copyright 2001, Travis Geiselbrecht. All rights reserved. 11 * Distributed under the terms of the NewOS License. 12 */ 13 14 15 #include <thread.h> 16 #include <arch_thread.h> 17 18 #include <arch_cpu.h> 19 #include <arch/thread.h> 20 #include <boot/stage2.h> 21 #include <kernel.h> 22 #include <thread.h> 23 #include <vm/vm_types.h> 24 #include <vm/VMAddressSpace.h> 25 #include <arch_vm.h> 26 //#include <arch/vm_translation_map.h> 27 28 #include <string.h> 29 30 #warning M68K: writeme! 31 // Valid initial arch_thread state. We just memcpy() it when initializing 32 // a new thread structure. 33 static struct arch_thread sInitialState; 34 35 Thread *gCurrentThread; 36 37 38 status_t 39 arch_thread_init(struct kernel_args *args) 40 { 41 // Initialize the static initial arch_thread state (sInitialState). 42 // Currently nothing to do, i.e. zero initialized is just fine. 43 44 return B_OK; 45 } 46 47 48 status_t 49 arch_team_init_team_struct(Team *team, bool kernel) 50 { 51 // Nothing to do. The structure is empty. 52 return B_OK; 53 } 54 55 56 status_t 57 arch_thread_init_thread_struct(Thread *thread) 58 { 59 // set up an initial state (stack & fpu) 60 memcpy(&thread->arch_info, &sInitialState, sizeof(struct arch_thread)); 61 62 return B_OK; 63 } 64 65 66 void 67 arch_thread_init_kthread_stack(Thread* thread, void* _stack, void* _stackTop, 68 void (*function)(void*), const void* data) 69 { 70 #warning ARM:WRITEME 71 } 72 73 74 status_t 75 arch_thread_init_tls(Thread *thread) 76 { 77 // TODO: Implement! 78 return B_OK; 79 } 80 81 82 void 83 arch_thread_context_switch(Thread *from, Thread *to) 84 { 85 /* addr_t newPageDirectory; 86 87 newPageDirectory = (addr_t)m68k_next_page_directory(from, to); 88 89 if ((newPageDirectory % B_PAGE_SIZE) != 0) 90 panic("arch_thread_context_switch: bad pgdir 0x%lx\n", newPageDirectory); 91 #warning M68K: export from arch_vm.c 92 m68k_set_pgdir(newPageDirectory); 93 m68k_context_switch(&from->arch_info.sp, to->arch_info.sp);*/ 94 #warning ARM:WRITEME 95 96 } 97 98 99 void 100 arch_thread_dump_info(void *info) 101 { 102 struct arch_thread *at = (struct arch_thread *)info; 103 104 dprintf("\tsp: %p\n", at->sp); 105 } 106 107 108 status_t 109 arch_thread_enter_userspace(Thread *thread, addr_t entry, void *arg1, void *arg2) 110 { 111 panic("arch_thread_enter_uspace(): not yet implemented\n"); 112 return B_ERROR; 113 } 114 115 116 bool 117 arch_on_signal_stack(Thread *thread) 118 { 119 return false; 120 } 121 122 123 status_t 124 arch_setup_signal_frame(Thread *thread, struct sigaction *sa, 125 struct signal_frame_data *signalFrameData) 126 { 127 return B_ERROR; 128 } 129 130 131 int64 132 arch_restore_signal_frame(struct signal_frame_data* signalFrameData) 133 { 134 return 0; 135 } 136 137 138 void 139 arch_check_syscall_restart(Thread *thread) 140 { 141 } 142 143 144 /** Saves everything needed to restore the frame in the child fork in the 145 * arch_fork_arg structure to be passed to arch_restore_fork_frame(). 146 * Also makes sure to return the right value. 147 */ 148 149 void 150 arch_store_fork_frame(struct arch_fork_arg *arg) 151 { 152 } 153 154 155 /** Restores the frame from a forked team as specified by the provided 156 * arch_fork_arg structure. 157 * Needs to be called from within the child team, ie. instead of 158 * arch_thread_enter_uspace() as thread "starter". 159 * This function does not return to the caller, but will enter userland 160 * in the child team at the same position where the parent team left of. 161 */ 162 163 void 164 arch_restore_fork_frame(struct arch_fork_arg *arg) 165 { 166 } 167 168