60,57 → 60,82 |
* @return Call identification, returns -1 on fatal error, |
-2 on 'Too many async request, handle answers first |
*/ |
static __native sys_ipc_call_sync(__native phoneid, __native arg1, |
__native arg2, __native *respdata) |
static __native sys_ipc_call_sync(__native phoneid, __native method, |
__native arg1, __native *data) |
{ |
call_t *call; |
call_t call; |
phone_t *phone; |
/* Special answerbox for synchronous messages */ |
|
if (phoneid >= IPC_MAX_PHONES) |
return -ENOENT; |
return IPC_CALLRET_FATAL; |
|
phone = &TASK->phones[phoneid]; |
if (!phone->callee) |
return -ENOENT; |
return IPC_CALLRET_FATAL; |
|
call = ipc_call_alloc(); |
call->data[0] = arg1; |
call->data[1] = arg2; |
ipc_call_init(&call); |
IPC_SET_METHOD(call.data, method); |
IPC_SET_ARG1(call.data, arg1); |
|
ipc_call_sync(phone, call); |
ipc_call_sync(phone, &call); |
|
copy_to_uspace(respdata, &call->data, sizeof(__native) * IPC_CALL_LEN); |
copy_to_uspace(data, &call.data, sizeof(call.data)); |
|
return 0; |
} |
|
static __native sys_ipc_call_sync_medium(__native phoneid, __native *data) |
{ |
call_t call; |
phone_t *phone; |
/* Special answerbox for synchronous messages */ |
|
if (phoneid >= IPC_MAX_PHONES) |
return IPC_CALLRET_FATAL; |
|
phone = &TASK->phones[phoneid]; |
if (!phone->callee) |
return IPC_CALLRET_FATAL; |
|
ipc_call_init(&call); |
copy_from_uspace(&call.data, data, sizeof(call.data)); |
|
ipc_call_sync(phone, &call); |
|
copy_to_uspace(data, &call.data, sizeof(call.data)); |
|
return 0; |
} |
|
|
/** Send an asynchronous call over ipc |
* |
* @return Call identification, returns -1 on fatal error, |
-2 on 'Too many async request, handle answers first |
*/ |
static __native sys_ipc_call_async(__native phoneid, __native arg1, |
__native arg2) |
static __native sys_ipc_call_async(__native phoneid, __native method, |
__native arg1, __native arg2) |
{ |
call_t *call; |
phone_t *phone; |
|
if (phoneid >= IPC_MAX_PHONES) |
return -ENOENT; |
return IPC_CALLRET_FATAL; |
|
phone = &TASK->phones[phoneid]; |
if (!phone->callee) |
return -ENOENT; |
return IPC_CALLRET_FATAL; |
|
|
/* TODO: Check that we did not exceed system imposed maximum |
* of asynchrnously sent messages |
* - the userspace should be able to handle it correctly |
*/ |
call = ipc_call_alloc(); |
call->data[0] = arg1; |
call->data[1] = arg2; |
IPC_SET_METHOD(call->data, method); |
IPC_SET_ARG1(call->data, arg1); |
IPC_SET_ARG2(call->data, arg2); |
|
ipc_call(phone, call); |
|
return (__native) call; |
117,7 → 142,8 |
} |
|
/** Send IPC answer */ |
static __native sys_ipc_answer(__native callid, __native arg1, __native arg2) |
static __native sys_ipc_answer(__native callid, __native retval, __native arg1, |
__native arg2) |
{ |
call_t *call; |
|
126,8 → 152,9 |
/* TODO: Check that the callid is in the dispatch table */ |
call = (call_t *) callid; |
|
call->data[0] = arg1; |
call->data[1] = arg2; |
IPC_SET_RETVAL(call->data, retval); |
IPC_SET_ARG1(call->data, arg1); |
IPC_SET_ARG2(call->data, arg2); |
|
ipc_answer(&TASK->answerbox, call); |
return 0; |
144,10 → 171,13 |
call_t *call; |
|
call = ipc_wait_for_call(&TASK->answerbox, flags); |
copy_to_uspace(calldata, &call->data, sizeof(__native) * IPC_CALL_LEN); |
|
if (call->flags & IPC_CALL_ANSWERED) |
return ((__native)call) | 1; |
copy_to_uspace(calldata, &call->data, sizeof(call->data)); |
if (call->flags & IPC_CALL_ANSWERED) { |
ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC)); |
ipc_call_free(call); |
return ((__native)call) | IPC_CALLID_ANSWERED; |
} |
return (__native)call; |
} |
|
156,6 → 186,7 |
sys_ctl, |
sys_io, |
sys_ipc_call_sync, |
sys_ipc_call_sync_medium, |
sys_ipc_call_async, |
sys_ipc_answer, |
sys_ipc_wait_for_call |