1 /* 2 * Copyright 2002-2011, The Haiku Team. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Copyright 2002, Travis Geiselbrecht. All rights reserved. 6 * Distributed under the terms of the NewOS License. 7 */ 8 #ifndef _KERNEL_ARCH_x86_THREAD_H 9 #define _KERNEL_ARCH_x86_THREAD_H 10 11 12 #include <arch/cpu.h> 13 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 20 struct iframe* i386_get_user_iframe(void); 21 struct iframe* i386_get_current_iframe(void); 22 struct iframe* i386_get_thread_user_iframe(Thread* thread); 23 24 uint32 x86_next_page_directory(Thread* from, Thread* to); 25 26 void x86_restart_syscall(struct iframe* frame); 27 28 void x86_set_tls_context(Thread* thread); 29 30 31 #ifdef __x86_64__ 32 33 34 // TODO 35 static inline Thread* 36 arch_thread_get_current_thread(void) 37 { 38 return NULL; 39 } 40 41 42 static inline void 43 arch_thread_set_current_thread(Thread* t) 44 { 45 46 } 47 48 49 #else // __x86_64__ 50 51 52 // override empty macro 53 #undef arch_syscall_64_bit_return_value 54 void arch_syscall_64_bit_return_value(void); 55 56 57 static inline Thread* 58 arch_thread_get_current_thread(void) 59 { 60 Thread* t = (Thread*)x86_read_dr3(); 61 return t; 62 } 63 64 65 static inline void 66 arch_thread_set_current_thread(Thread* t) 67 { 68 x86_write_dr3(t); 69 } 70 71 72 #endif // __x86_64__ 73 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 #endif /* _KERNEL_ARCH_x86_THREAD_H */ 80