1 /* 2 * Copyright 2003-2019, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Ingo Weinhold <bonefish@cs.tu-berlin.de> 7 * Jonas Sundström <jonas@kirilla.com> 8 */ 9 #ifndef _KERNEL_ARCH_RISCV64_THREAD_H 10 #define _KERNEL_ARCH_RISCV64_THREAD_H 11 12 #include <arch/cpu.h> 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 19 static inline Thread* 20 arch_thread_get_current_thread(void) 21 { 22 Thread* t; 23 asm volatile("mv %0, tp" : "=r" (t)); 24 return t; 25 } 26 27 28 static inline void 29 arch_thread_set_current_thread(Thread* t) 30 { 31 asm volatile("mv tp, %0" : : "r" (t)); 32 } 33 34 35 #ifdef __cplusplus 36 } 37 #endif 38 39 40 #endif /* _KERNEL_ARCH_RISCV64_THREAD_H */ 41