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
16extern "C" {
17#endif
18
19void arm_push_iframe(struct iframe_stack *stack, struct iframe *frame);
20void arm_pop_iframe(struct iframe_stack *stack);
21struct iframe *arm_get_user_iframe(void);
22
23
24extern inline Thread *
25arch_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
34extern inline void
35arch_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