From f912f28731535412704bd14f90b9f40529486adb Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Mon, 9 Nov 2009 22:59:24 +0200 Subject: [PATCH] Clarified a few confusing definitions in ipc.c --- conts/posix/test0/main.c | 3 +-- include/l4/api/ipc.h | 4 ++-- include/l4/generic/tcb.h | 2 +- src/api/ipc.c | 24 ++++++++++++------------ 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/conts/posix/test0/main.c b/conts/posix/test0/main.c index 130ac29..47e2e6e 100644 --- a/conts/posix/test0/main.c +++ b/conts/posix/test0/main.c @@ -63,12 +63,11 @@ int main(int argc, char *argv[]) user_mutex_test(); } -/* exectest(parent_of_all); while (1) wait_pager(pagerid); -*/ + return 0; } diff --git a/include/l4/api/ipc.h b/include/l4/api/ipc.h index 84f81ca..4b291e1 100644 --- a/include/l4/api/ipc.h +++ b/include/l4/api/ipc.h @@ -39,10 +39,10 @@ #define IPC_EXTENDED_MAX_SIZE L4_IPC_EXTENDED_MAX_SIZE /* - * ipc syscall uses an ipc_type variable and send/recv + * ipc syscall uses an ipc_dir variable and send/recv * details are embedded in this variable. */ -enum IPC_TYPE { +enum IPC_DIR { IPC_INVALID = 0, IPC_SEND = 1, IPC_RECV = 2, diff --git a/include/l4/generic/tcb.h b/include/l4/generic/tcb.h index 787ba09..799ec77 100644 --- a/include/l4/generic/tcb.h +++ b/include/l4/generic/tcb.h @@ -48,7 +48,7 @@ static inline l4id_t tid_to_cid(l4id_t tid) return (tid & TASK_CID_MASK) >> TASK_CID_SHIFT; } -static inline int task_id_special(l4id_t id) +static inline int tid_special_value(l4id_t id) { /* Special ids have top 2 nibbles all set */ return (id & TASK_CID_MASK) == TASK_CID_MASK; diff --git a/src/api/ipc.c b/src/api/ipc.c index 95c39d9..799364f 100644 --- a/src/api/ipc.c +++ b/src/api/ipc.c @@ -471,12 +471,12 @@ int ipc_send_extended(l4id_t recv_tid, unsigned int flags) static inline int __sys_ipc(l4id_t to, l4id_t from, - unsigned int ipc_type, unsigned int flags) + unsigned int ipc_dir, unsigned int flags) { int ret; if (ipc_flags_get_type(flags) == IPC_FLAGS_EXTENDED) { - switch (ipc_type) { + switch (ipc_dir) { case IPC_SEND: ret = ipc_send_extended(to, flags); break; @@ -492,7 +492,7 @@ static inline int __sys_ipc(l4id_t to, l4id_t from, ret = -ENOSYS; } } else { - switch (ipc_type) { + switch (ipc_dir) { case IPC_SEND: ret = ipc_send(to, flags); break; @@ -535,18 +535,18 @@ void printk_sysregs(syscall_context_t *regs) */ int sys_ipc(l4id_t to, l4id_t from, unsigned int flags) { - unsigned int ipc_type = 0; + unsigned int ipc_dir = 0; int ret = 0; struct ktcb *t = current; if (!t); /* Check arguments */ - if (task_id_special(from) && + if (tid_special_value(from) && from != L4_ANYTHREAD && from != L4_NILTHREAD) { ret = -EINVAL; goto error; } - if (task_id_special(to) && + if (tid_special_value(to) && to != L4_ANYTHREAD && to != L4_NILTHREAD) { ret = -EINVAL; goto error; @@ -559,24 +559,24 @@ int sys_ipc(l4id_t to, l4id_t from, unsigned int flags) } /* [0] for Send */ - ipc_type |= (to != L4_NILTHREAD); + ipc_dir |= (to != L4_NILTHREAD); /* [1] for Receive, [1:0] for both */ - ipc_type |= ((from != L4_NILTHREAD) << 1); + ipc_dir |= ((from != L4_NILTHREAD) << 1); - if (ipc_type == IPC_INVALID) { + if (ipc_dir == IPC_INVALID) { ret = -EINVAL; goto error; } /* Everything in place, now check capability */ - if ((ret = cap_ipc_check(to, from, flags, ipc_type)) < 0) + if ((ret = cap_ipc_check(to, from, flags, ipc_dir)) < 0) return ret; /* Encode ipc type in task flags */ tcb_set_ipc_flags(current, flags); - if ((ret = __sys_ipc(to, from, ipc_type, flags)) < 0) + if ((ret = __sys_ipc(to, from, ipc_dir, flags)) < 0) goto error; return ret; @@ -587,7 +587,7 @@ error: */ //printk("Erroneous ipc by: %d. from: %d, to: %d, Err: %d\n", // current->tid, from, to, ret); - ipc_type = IPC_INVALID; + ipc_dir = IPC_INVALID; return ret; }