[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wortel syscall wrappers
From: |
Niels Möller |
Subject: |
wortel syscall wrappers |
Date: |
20 Jan 2004 13:52:20 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Does this way of doing syscall wrappers look sane?
The code compiles, but is so far utterly untested.
Client wrappers, from the task server:
/* Syscall wrappers */
#define WORTEL_MSG_SPACE_CONTROL 10
#define WORTEL_MSG_THREAD_CONTROL 11
static l4_word_t
wortel_space_control (l4_thread_id_t space, l4_word_t control,
l4_fpage_t kip_area, l4_fpage_t utcb_area,
l4_thread_id_t redirector, l4_word_t *old_control)
{
l4_msg_t msg;
l4_msg_tag_t tag;
l4_msg_clear (&msg);
l4_set_msg_label (&msg, WORTEL_MSG_SPACE_CONTROL);
l4_msg_append_word (&msg, TASK_WORTEL_CAP);
l4_msg_append_word (&msg, space.raw);
l4_msg_append_word (&msg, control);
l4_msg_append_word (&msg, kip_area.raw);
l4_msg_append_word (&msg, utcb_area.raw);
l4_msg_append_word (&msg, redirector.raw);
l4_msg_load (&msg);
/* FIXME: Hard coded thread ID. */
tag = l4_call (l4_global_id (l4_thread_user_base () + 2, 1));
if (l4_ipc_failed (tag))
return 0;
if (l4_label (tag) == 0)
return 0;
if (l4_untyped_words (tag) != 1
|| l4_typed_words (tag) != 0)
panic ("Invalid format of space_control reply");
l4_msg_store (tag, &msg);
*old_control = l4_msg_word (&msg, 0);
return 1;
}
static l4_word_t
wortel_thread_control (l4_thread_id_t dest, l4_thread_id_t space,
l4_thread_id_t scheduler, l4_thread_id_t pager,
void *utcb_loc)
{
l4_msg_t msg;
l4_msg_tag_t tag;
l4_msg_clear (&msg);
l4_set_msg_label (&msg, WORTEL_MSG_THREAD_CONTROL);
l4_msg_append_word (&msg, TASK_WORTEL_CAP);
l4_msg_append_word (&msg, dest.raw);
l4_msg_append_word (&msg, space.raw);
l4_msg_append_word (&msg, scheduler.raw);
l4_msg_append_word (&msg, pager.raw);
l4_msg_append_word (&msg, (l4_word_t) utcb_loc);
l4_msg_load (&msg);
/* FIXME: Hard coded thread ID. */
tag = l4_call (l4_global_id (l4_thread_user_base () + 2, 1));
if (l4_ipc_failed (tag))
return 0;
return l4_label (tag);
}
Patch to wortel.c:
diff -u -a -p -r1.19 wortel.c
--- wortel/wortel.c 2 Oct 2003 10:39:36 -0000 1.19
+++ wortel/wortel.c 20 Jan 2004 12:44:14 -0000
@@ -630,6 +715,68 @@ serve_requests (void)
putchar (chr);
/* No reply needed. */
continue;
+ }
+#define WORTEL_MSG_SPACE_CONTROL 10
+#define WORTEL_MSG_THREAD_CONTROL 11
+ else if (label == WORTEL_MSG_SPACE_CONTROL)
+ {
+ l4_word_t old_control = 0;
+ int res;
+
+ l4_thread_id_t space;
+ l4_word_t control;
+ l4_fpage_t kip;
+ l4_fpage_t utcb;
+ l4_thread_id_t redirect;
+
+ if (l4_untyped_words (msg_tag) != 6
+ || l4_typed_words (msg_tag) != 0)
+ panic ("Invalid format of space_control msg");
+
+ /* FIXME: Need we check that no local thread id:s are used? */
+ space.raw = l4_msg_word(&msg, 1);
+ control = l4_msg_word(&msg, 2);
+ kip.raw = l4_msg_word(&msg, 3);
+ utcb.raw = l4_msg_word(&msg, 4);
+ redirect.raw = l4_msg_word(&msg, 5);
+
+ res = l4_space_control(space, control, kip, utcb, redirect,
+ &old_control);
+
+ l4_msg_clear (&msg);
+ l4_set_msg_label (&msg, res);
+ if (res)
+ l4_msg_append_word (&msg, old_control);
+ l4_msg_load (&msg);
+ l4_reply (from);
+ }
+ else if (label == WORTEL_MSG_THREAD_CONTROL)
+ {
+ int res;
+
+ l4_thread_id_t dest;
+ l4_thread_id_t space;
+ l4_thread_id_t scheduler;
+ l4_thread_id_t pager;
+ void *utcb;
+
+ if (l4_untyped_words (msg_tag) != 6
+ || l4_typed_words (msg_tag) != 0)
+ panic ("Invalid format of thread_control msg");
+
+ dest.raw = l4_msg_word(&msg, 1);
+ space.raw = l4_msg_word(&msg, 2);
+ scheduler.raw = l4_msg_word(&msg, 3);
+ pager.raw = l4_msg_word(&msg, 4);
+ utcb = (void *) l4_msg_word(&msg, 5);
+
+ /* FIXME: Need we check that no local thread id:s are used? */
+ res = l4_thread_control(dest, space, scheduler, pager, utcb);
+
+ l4_msg_clear (&msg);
+ l4_set_msg_label (&msg, res);
+ l4_msg_load (&msg);
+ l4_reply (from);
}
else if (label == WORTEL_MSG_SHUTDOWN)
panic ("Bootstrap failed");
Regards,
/Niels
- wortel syscall wrappers,
Niels Möller <=