1bb1325a3SFrançois Revol /*
2*c0a76012SDavid Karoly * Copyright 2003-2022, Haiku Inc. All rights reserved.
3bb1325a3SFrançois Revol * Distributed under the terms of the MIT License.
4bb1325a3SFrançois Revol *
5bb1325a3SFrançois Revol * Authors:
6bb1325a3SFrançois Revol * Axel Dörfler <axeld@pinc-software.de>
7bb1325a3SFrançois Revol * Ingo Weinhold <bonefish@cs.tu-berlin.de>
8bb1325a3SFrançois Revol * Johannes Wischert <johanneswi@gmail.com>
9bb1325a3SFrançois Revol */
10bb1325a3SFrançois Revol #ifndef _KERNEL_ARCH_ARM_THREAD_H
11bb1325a3SFrançois Revol #define _KERNEL_ARCH_ARM_THREAD_H
12bb1325a3SFrançois Revol
13bb1325a3SFrançois Revol #include <arch/cpu.h>
14bb1325a3SFrançois Revol
15bb1325a3SFrançois Revol #ifdef __cplusplus
16bb1325a3SFrançois Revol extern "C" {
17bb1325a3SFrançois Revol #endif
18bb1325a3SFrançois Revol
19bb1325a3SFrançois Revol void arm_push_iframe(struct iframe_stack *stack, struct iframe *frame);
20bb1325a3SFrançois Revol void arm_pop_iframe(struct iframe_stack *stack);
21bb1325a3SFrançois Revol struct iframe *arm_get_user_iframe(void);
22bb1325a3SFrançois Revol
23bb1325a3SFrançois Revol
244535495dSIngo Weinhold extern inline Thread *
arch_thread_get_current_thread(void)25bb1325a3SFrançois Revol arch_thread_get_current_thread(void)
26bb1325a3SFrançois Revol {
27*c0a76012SDavid Karoly // read pointer to thread data structure from TPIDRPRW
28*c0a76012SDavid Karoly Thread* t;
29*c0a76012SDavid Karoly asm volatile("MRC p15, 0, %0, c13, c0, 4" : "=r" (t));
30*c0a76012SDavid Karoly return t;
31bb1325a3SFrançois Revol }
32bb1325a3SFrançois Revol
33bb1325a3SFrançois Revol
34bb1325a3SFrançois Revol extern inline void
arch_thread_set_current_thread(Thread * t)354535495dSIngo Weinhold arch_thread_set_current_thread(Thread *t)
36bb1325a3SFrançois Revol {
37*c0a76012SDavid Karoly // set TPIDRPRW to point to thread data structure
38*c0a76012SDavid Karoly asm volatile("MCR p15, 0, %0, c13, c0, 4" : : "r" (t));
39bb1325a3SFrançois Revol }
40bb1325a3SFrançois Revol
41bb1325a3SFrançois Revol #ifdef __cplusplus
42bb1325a3SFrançois Revol }
43bb1325a3SFrançois Revol #endif
44bb1325a3SFrançois Revol
45bb1325a3SFrançois Revol
46bb1325a3SFrançois Revol #endif /* _KERNEL_ARCH_ARM_THREAD_H */
47