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