xref: /haiku/headers/private/kernel/arch/m68k/arch_thread.h (revision 0d452c8f34013b611a54c746a71c05e28796eae2)
1 /*
2  * Copyright 2003-2011, 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  */
9 #ifndef _KERNEL_ARCH_M68K_THREAD_H
10 #define _KERNEL_ARCH_M68K_THREAD_H
11 
12 #include <arch/cpu.h>
13 #include <arch/thread.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 void m68k_push_iframe(struct iframe_stack *stack, struct iframe *frame);
20 void m68k_pop_iframe(struct iframe_stack *stack);
21 struct iframe *m68k_get_user_iframe(void);
22 
23 /* as we won't support SMP on m68k (yet?) we can use a global here */
24 extern Thread *gCurrentThread;
25 
26 extern inline Thread *
27 arch_thread_get_current_thread(void)
28 {
29 	return gCurrentThread;
30 }
31 
32 
33 extern inline void
34 arch_thread_set_current_thread(Thread *t)
35 {
36 	gCurrentThread = t;
37 }
38 
39 #if 0
40 /* this would only work on 030... */
41 
42 extern inline Thread *
43 arch_thread_get_current_thread(void)
44 {
45 	uint64 v = 0;
46 	asm volatile("pmove %%srp,(%0)" : : "a"(&v));
47 	return (Thread *)(uint32)(v & 0xffffffff);
48 }
49 
50 
51 extern inline void
52 arch_thread_set_current_thread(Thread *t)
53 {
54 	uint64 v;
55 	asm volatile("pmove %%srp,(%0)\n" \
56 			"move %1,(4,%0)\n" \
57 			"pmove (%0),%%srp" : : "a"(&v), "d"(t));
58 }
59 #endif
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 
66 #endif /* _KERNEL_ARCH_M68K_THREAD_H */
67