From e8bb529dcb47a7d71f451000242dfcaf83e2b70c Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Tue, 22 Apr 2008 00:30:07 +0100 Subject: [PATCH] Now we save/restore utcb registers if we do a second ipc before returning the first. --- tasks/fs0/src/syscalls.c | 3 +++ tasks/libl4/include/l4lib/arch-arm/syslib.h | 28 +++++++++++++++++++++ tasks/libl4/include/l4lib/arch-arm/utcb.h | 3 ++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/tasks/fs0/src/syscalls.c b/tasks/fs0/src/syscalls.c index 2daf131..fa06846 100644 --- a/tasks/fs0/src/syscalls.c +++ b/tasks/fs0/src/syscalls.c @@ -30,6 +30,8 @@ int pager_sys_open(l4id_t sender, int fd, unsigned long vnum, unsigned long size { int err; + l4_save_ipcregs(); + write_mr(L4SYS_ARG0, sender); write_mr(L4SYS_ARG1, fd); write_mr(L4SYS_ARG2, vnum); @@ -46,6 +48,7 @@ int pager_sys_open(l4id_t sender, int fd, unsigned long vnum, unsigned long size printf("%s: Pager open Error: %d.\n", __FUNCTION__, fd); return err; } + l4_restore_ipcregs(); return 0; } diff --git a/tasks/libl4/include/l4lib/arch-arm/syslib.h b/tasks/libl4/include/l4lib/arch-arm/syslib.h index e27aa8f..3443814 100644 --- a/tasks/libl4/include/l4lib/arch-arm/syslib.h +++ b/tasks/libl4/include/l4lib/arch-arm/syslib.h @@ -38,6 +38,17 @@ static inline l4id_t l4_get_sender(void) return (l4id_t)read_mr(MR_SENDER); } +/* + * When doing an ipc the sender never has to be explicitly set in + * the utcb via this function since it is passed in the argument + * registers. This is only used for restoring the sender on the + * utcb in order to complete an earlier ipc. + */ +static inline void l4_set_sender(l4id_t sender) +{ + write_mr(MR_SENDER, sender); +} + static inline unsigned int l4_get_tag(void) { return read_mr(MR_TAG); @@ -48,6 +59,23 @@ static inline void l4_set_tag(unsigned int tag) write_mr(MR_TAG, tag); } +/* + * If we're about to do another ipc, this saves the last ipc's + * parameters such as the sender and tag information. + * Any previously saved data in save slots are destroyed. + */ +static inline void l4_save_ipcregs(void) +{ + l4_get_utcb()->saved_sender = l4_get_sender(); + l4_get_utcb()->saved_tag = l4_get_tag(); +} + +static inline void l4_restore_ipcregs(void) +{ + l4_set_tag(l4_get_utcb()->saved_tag); + l4_set_sender(l4_get_utcb()->saved_sender); +} + static inline l4id_t self_tid(void) { struct task_ids ids; diff --git a/tasks/libl4/include/l4lib/arch-arm/utcb.h b/tasks/libl4/include/l4lib/arch-arm/utcb.h index 3e6fb5b..b001b0b 100644 --- a/tasks/libl4/include/l4lib/arch-arm/utcb.h +++ b/tasks/libl4/include/l4lib/arch-arm/utcb.h @@ -25,7 +25,8 @@ */ struct utcb { u32 mr[MR_TOTAL]; - u32 tid; /* Thread id */ + u32 saved_tag; + u32 saved_sender; } __attribute__((__packed__)); extern struct utcb utcb;