summaryrefslogtreecommitdiff
path: root/hurd/thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'hurd/thread.h')
-rw-r--r--hurd/thread.h103
1 files changed, 87 insertions, 16 deletions
diff --git a/hurd/thread.h b/hurd/thread.h
index ec6b1af..709e9ec 100644
--- a/hurd/thread.h
+++ b/hurd/thread.h
@@ -26,21 +26,63 @@
#include <hurd/startup.h>
#include <hurd/addr-trans.h>
#include <l4/syscall.h>
+#include <l4/ipc.h>
enum
{
RM_thread_exregs = 600,
};
+struct exception_page
+{
+ union
+ {
+ /* Whether the thread is in activation mode or not. If so, no
+ exception will be delivered.
+
+ **** ia32-exception-entry.S silently depends on the layout of
+ this structure **** */
+ struct
+ {
+ /* Whether the thread is in activated mode. */
+ l4_word_t activated_mode : 1;
+ /* Set by the kernel to indicated that there is a pending
+ message. */
+ l4_word_t pending_message : 1;
+ /* Set by the kernel to indicate whether the thread was
+ interrupted while the EIP is in the transition range. */
+ l4_word_t interrupt_in_transition : 1;
+
+ /* The value of the IP and SP when the thread was running. */
+ l4_word_t saved_ip;
+ l4_word_t saved_sp;
+ /* The state of the thread (as returned by _L4_exchange_regs) */
+ l4_word_t saved_thread_state;
+
+ l4_word_t exception_handler_sp;
+ l4_word_t exception_handler_ip;
+ l4_word_t exception_handler_end;
+
+ /* The exception. */
+ l4_msg_t exception;
+ };
+ char data[PAGESIZE];
+ };
+};
+
enum
{
+ /* Root of the address space. */
THREAD_ASPACE_SLOT = 0,
+ /* The activity the thread is bound to. */
THREAD_ACTIVITY_SLOT = 1,
+ /* Where exceptions are saved. Must be a cap_page. */
+ THREAD_EXCEPTION_PAGE_SLOT = 1,
};
enum
{
- HURD_EXREGS_EXCEPTION_THREAD = 0x1000,
+ HURD_EXREGS_SET_EXCEPTION_PAGE = 0x1000,
HURD_EXREGS_SET_ASPACE = 0x800,
HURD_EXREGS_SET_ACTIVITY = 0x400,
@@ -49,7 +91,8 @@ enum
HURD_EXREGS_SET_SP_IP = _L4_XCHG_REGS_SET_SP | _L4_XCHG_REGS_SET_IP,
HURD_EXREGS_SET_EFLAGS = _L4_XCHG_REGS_SET_FLAGS,
HURD_EXREGS_SET_USER_HANDLE = _L4_XCHG_REGS_SET_USER_HANDLE,
- HURD_EXREGS_SET_REGS = (HURD_EXREGS_SET_ASPACE
+ HURD_EXREGS_SET_REGS = (HURD_EXREGS_SET_EXCEPTION_PAGE
+ | HURD_EXREGS_SET_ASPACE
| HURD_EXREGS_SET_ACTIVITY
| HURD_EXREGS_SET_SP
| HURD_EXREGS_SET_IP
@@ -66,6 +109,8 @@ enum
HURD_EXREGS_ABORT_IPC = HURD_EXREGS_ABORT_SEND | _L4_XCHG_REGS_CANCEL_RECV,
};
+typedef void (*hurd_exception_handler_t) (struct exception_page *);
+
#define RPC_STUB_PREFIX rm
#define RPC_ID_PREFIX RM
#undef RPC_TARGET_NEED_ARG
@@ -77,17 +122,44 @@ enum
#include <hurd/rpc.h>
+struct hurd_thread_exregs_in
+{
+ l4_word_t control;
+
+ addr_t aspace;
+ l4_word_t aspace_addr_trans_flags;
+ struct cap_addr_trans aspace_addr_trans;
+
+ addr_t activity;
+
+ addr_t exception_page;
+
+ l4_word_t sp;
+ l4_word_t ip;
+ l4_word_t eflags;
+ l4_word_t user_handle;
+
+ addr_t aspace_out;
+ addr_t activity_out;
+ addr_t exception_page_out;
+};
+
+struct hurd_thread_exregs_out
+{
+ l4_word_t sp;
+ l4_word_t ip;
+ l4_word_t eflags;
+ l4_word_t user_handle;
+};
+
/* l4_exregs wrapper. */
-RPC (thread_exregs, 13, 4, addr_t, principal, addr_t, thread,
+RPC (thread_exregs, 4, 1,
+ addr_t, principal,
+ addr_t, thread,
l4_word_t, control,
- addr_t, aspace, l4_word_t, flags, struct cap_addr_trans, aspace_trans,
- addr_t, activity,
- l4_word_t, sp, l4_word_t, ip, l4_word_t, eflags,
- l4_word_t, user_handler,
- addr_t, aspace_out, addr_t, activity_out,
- l4_word_t *, sp_out, l4_word_t *, ip_out, l4_word_t *, eflags_out,
- l4_word_t *, user_handler_out)
-
+ struct hurd_thread_exregs_in, in,
+ struct hurd_thread_exregs_out *, out)
+
#undef RPC_STUB_PREFIX
#undef RPC_ID_PREFIX
#undef RPC_TARGET
@@ -95,13 +167,12 @@ RPC (thread_exregs, 13, 4, addr_t, principal, addr_t, thread,
static inline error_t
thread_stop (addr_t thread)
{
- l4_word_t dummy = 0;
+ struct hurd_thread_exregs_in in;
+ struct hurd_thread_exregs_out out;
+
return rm_thread_exregs (ADDR_VOID, thread,
HURD_EXREGS_STOP | HURD_EXREGS_ABORT_IPC,
- ADDR_VOID, 0, CAP_ADDR_TRANS_VOID, ADDR_VOID,
- 0, 0, 0, 0,
- ADDR_VOID, ADDR_VOID,
- &dummy, &dummy, &dummy, &dummy);
+ in, &out);
}
#endif