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