xref: /haiku/headers/private/kernel/arch/arm/arch_thread.h (revision 52c4471a3024d2eb81fe88e2c3982b9f8daa5e56)
1 /*
2  * Copyright 2003-2022, 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  *		Johannes Wischert <johanneswi@gmail.com>
9  */
10 #ifndef _KERNEL_ARCH_ARM_THREAD_H
11 #define _KERNEL_ARCH_ARM_THREAD_H
12 
13 #include <arch/cpu.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 void arm_push_iframe(struct iframe_stack *stack, struct iframe *frame);
20 void arm_pop_iframe(struct iframe_stack *stack);
21 struct iframe *arm_get_user_iframe(void);
22 
23 
24 extern inline Thread *
25 arch_thread_get_current_thread(void)
26 {
27 	// read pointer to thread data structure from TPIDRPRW
28 	Thread* t;
29 	asm volatile("MRC p15, 0, %0, c13, c0, 4" : "=r" (t));
30 	return t;
31 }
32 
33 
34 extern inline void
35 arch_thread_set_current_thread(Thread *t)
36 {
37 	// set TPIDRPRW to point to thread data structure
38 	asm volatile("MCR p15, 0, %0, c13, c0, 4" : : "r" (t));
39 }
40 
41 #ifdef __cplusplus
42 }
43 #endif
44 
45 
46 #endif /* _KERNEL_ARCH_ARM_THREAD_H */
47