2002-07-09 16:24:59 +04:00
|
|
|
/*
|
2011-01-11 00:54:38 +03:00
|
|
|
* Copyright 2002-2011, The Haiku Team. All rights reserved.
|
2005-04-04 18:13:25 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Copyright 2002, Travis Geiselbrecht. All rights reserved.
|
|
|
|
* Distributed under the terms of the NewOS License.
|
|
|
|
*/
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _KERNEL_ARCH_x86_THREAD_H
|
|
|
|
#define _KERNEL_ARCH_x86_THREAD_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <arch/cpu.h>
|
|
|
|
|
2002-08-14 01:42:53 +04:00
|
|
|
|
2005-04-04 18:13:25 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-03-02 02:56:52 +03:00
|
|
|
struct iframe *i386_get_user_iframe(void);
|
2008-08-23 03:55:43 +04:00
|
|
|
struct iframe *i386_get_current_iframe(void);
|
2011-01-11 00:54:38 +03:00
|
|
|
struct iframe *i386_get_thread_user_iframe(Thread *thread);
|
2009-06-14 16:14:06 +04:00
|
|
|
|
2011-01-11 00:54:38 +03:00
|
|
|
uint32 x86_next_page_directory(Thread *from, Thread *to);
|
2002-08-14 01:42:53 +04:00
|
|
|
|
2011-11-25 18:51:13 +04:00
|
|
|
void x86_restart_syscall(struct iframe *frame);
|
|
|
|
|
|
|
|
void x86_set_tls_context(Thread *thread);
|
axeld + bonefish:
* Implemented automatic syscall restarts:
- A syscall can indicate that it has been interrupted and can be
restarted by setting a respective bit in thread::flags. It can
store parameters it wants to be preserved for the restart in
thread::syscall_restart::parameters. Another thread::flags bit
indicates whether it has been restarted.
- handle_signals() clears the restart flag, if the handled signal
has a handler function installed and SA_RESTART is not set. Another
thread flag (THREAD_FLAGS_DONT_RESTART_SYSCALL) can prevent syscalls
from being restarted, even if they could be (not used yet, but we
might want to use it in resume_thread(), so that we stay
behaviorally compatible with BeOS).
- The architecture specific syscall handler restarts the syscall, if
the restart flag is set. Implemented for x86 only.
- Added some support functions in the private <syscall_restart.h> to
simplify the syscall restart code in the syscalls.
- Adjusted all syscalls that can potentially be restarted accordingly.
- _user_ioctl() sets new thread flag THREAD_FLAGS_IOCTL_SYSCALL while
calling the underlying FS's/driver's hook, so that syscall restarts
can also be supported there.
* thread_at_kernel_exit() invokes handle_signals() in a loop now, as
long as the latter indicates that the thread shall be suspended, so
that after waking up signals received in the meantime will be handled
before the thread returns to userland. Adjusted handle_signals()
accordingly -- when encountering a suspending signal we don't check
for further signals.
* Fixed sigsuspend(): Suspending the thread and rescheduling doesn't
result in the correct behavior. Instead we employ a temporary
condition variable and interruptably wait on it. The POSIX test
suite test passes, now.
* Made the switch_sem[_etc]() behavior on interruption consistent.
Depending on when the signal arrived (before the call or when already
waiting) the first semaphore would or wouldn't be released. Now we
consistently release it.
* Refactored _user_{read,write}[v]() syscalls. Use a common function for
either pair. The iovec version doesn't fail anymore, if anything could
be read/written at all. It also checks whether a complete vector
could be read/written, so that we won't skip data, if the underlying
FS/driver couldn't read/write more ATM.
* Some refactoring in the x86 syscall handler: The int 99 and sysenter
handlers use a common subroutine to avoid code duplication.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23983 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-02-17 18:48:30 +03:00
|
|
|
|
2008-01-11 03:36:44 +03:00
|
|
|
// override empty macro
|
|
|
|
#undef arch_syscall_64_bit_return_value
|
2008-01-19 17:26:59 +03:00
|
|
|
void arch_syscall_64_bit_return_value(void);
|
2008-01-11 03:36:44 +03:00
|
|
|
|
2002-08-14 01:42:53 +04:00
|
|
|
|
2002-10-08 07:19:57 +04:00
|
|
|
static
|
2011-01-11 00:54:38 +03:00
|
|
|
inline Thread *
|
2002-10-08 07:19:57 +04:00
|
|
|
arch_thread_get_current_thread(void)
|
|
|
|
{
|
2011-01-11 00:54:38 +03:00
|
|
|
Thread *t;
|
2002-07-09 16:24:59 +04:00
|
|
|
read_dr3(t);
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2002-10-08 07:19:57 +04:00
|
|
|
static inline void
|
2011-01-11 00:54:38 +03:00
|
|
|
arch_thread_set_current_thread(Thread *t)
|
2002-10-08 07:19:57 +04:00
|
|
|
{
|
2002-07-09 16:24:59 +04:00
|
|
|
write_dr3(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _KERNEL_ARCH_x86_THREAD_H */
|
|
|
|
|