Clarified a few confusing definitions in ipc.c

This commit is contained in:
Bahadir Balban
2009-11-09 22:59:24 +02:00
parent da8b0a90f3
commit f912f28731
4 changed files with 16 additions and 17 deletions

View File

@@ -63,12 +63,11 @@ int main(int argc, char *argv[])
user_mutex_test();
}
/*
exectest(parent_of_all);
while (1)
wait_pager(pagerid);
*/
return 0;
}

View File

@@ -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,

View File

@@ -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;

View File

@@ -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;
}