Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1363 → Rev 1364

/kernel/trunk/generic/include/ipc/sysipc.h
31,6 → 31,7
 
#include <ipc/ipc.h>
#include <ipc/irq.h>
#include <arch/types.h>
 
__native sys_ipc_call_sync_fast(__native phoneid, __native method,
__native arg1, ipc_data_t *data);
42,7 → 43,7
__native sys_ipc_answer_fast(__native callid, __native retval,
__native arg1, __native arg2);
__native sys_ipc_answer(__native callid, ipc_data_t *data);
__native sys_ipc_wait_for_call(ipc_data_t *calldata, __native flags);
__native sys_ipc_wait_for_call(ipc_data_t *calldata, __u32 usec, int nonblocking);
__native sys_ipc_forward_fast(__native callid, __native phoneid,
__native method, __native arg1);
__native sys_ipc_hangup(int phoneid);
/kernel/trunk/generic/include/ipc/ipc.h
45,9 → 45,6
#define IPC_CALL_CONN_ME_TO (1<<4) /* Identify connect_me_to */
#define IPC_CALL_NOTIF (1<<5) /* Interrupt notification */
 
/* Flags for ipc_wait_for_call */
#define IPC_WAIT_NONBLOCKING 1
 
/* Flags of callid (the addresses are aligned at least to 4,
* that is why we can use bottom 2 bits of the call address
*/
200,7 → 197,7
}call_t;
 
extern void ipc_init(void);
extern call_t * ipc_wait_for_call(answerbox_t *box, int flags);
extern call_t * ipc_wait_for_call(answerbox_t *box, __u32 usec, int nonblocking);
extern void ipc_answer(answerbox_t *box, call_t *request);
extern int ipc_call(phone_t *phone, call_t *call);
extern void ipc_call_sync(phone_t *phone, call_t *request);
216,7 → 213,6
extern int ipc_phone_hangup(phone_t *phone);
extern void ipc_backsend_err(phone_t *phone, call_t *call, __native err);
 
 
extern answerbox_t *ipc_phone_0;
 
#endif
/kernel/trunk/generic/src/ipc/sysipc.c
468,15 → 468,17
/** Wait for incoming ipc call or answer
*
* @param calldata Pointer to buffer where the call/answer data is stored
* @param flags
* @param usec Timeout. See waitq_sleep_timeout() for explanation.
* @param nonblocking See waitq_sleep_timeout() for explanation.
*
* @return Callid, if callid & 1, then the call is answer
*/
__native sys_ipc_wait_for_call(ipc_data_t *calldata, __native flags)
__native sys_ipc_wait_for_call(ipc_data_t *calldata, __u32 usec, int nonblocking)
{
call_t *call;
 
restart:
call = ipc_wait_for_call(&TASK->answerbox, flags);
call = ipc_wait_for_call(&TASK->answerbox, usec, nonblocking);
if (!call)
return 0;
 
/kernel/trunk/generic/src/ipc/ipc.c
33,6 → 33,7
 
#include <synch/spinlock.h>
#include <synch/waitq.h>
#include <synch/synch.h>
#include <ipc/ipc.h>
#include <errno.h>
#include <mm/slab.h>
141,7 → 142,7
request->callerbox = &sync_box;
 
ipc_call(phone, request);
ipc_wait_for_call(&sync_box, 0);
ipc_wait_for_call(&sync_box, SYNCH_NO_TIMEOUT, SYNCH_BLOCKING);
}
 
/** Answer message that was not dispatched and is not entered in
301,20 → 302,24
 
/** Wait for phone call
*
* @param box Answerbox expecting the call.
* @param usec Timeout in microseconds. See documentation for waitq_sleep_timeout() for
* decription of its special meaning.
* @param nonblocking Blocking vs. non-blocking operation mode switch. See documentation
* for waitq_sleep_timeout() for description of its special meaning.
* @return Recived message address
* - to distinguish between call and answer, look at call->flags
*/
call_t * ipc_wait_for_call(answerbox_t *box, int flags)
call_t * ipc_wait_for_call(answerbox_t *box, __u32 usec, int nonblocking)
{
call_t *request;
ipl_t ipl;
int rc;
 
restart:
if (flags & IPC_WAIT_NONBLOCKING) {
if (waitq_sleep_timeout(&box->wq,0,1) == ESYNCH_WOULD_BLOCK)
return NULL;
} else
waitq_sleep(&box->wq);
restart:
rc = waitq_sleep_timeout(&box->wq, usec, nonblocking);
if (SYNCH_FAILED(rc))
return NULL;
spinlock_lock(&box->lock);
if (!list_empty(&box->irq_notifs)) {
407,7 → 412,7
/* Wait for all async answers to arrive */
while (atomic_get(&task->active_calls)) {
call = ipc_wait_for_call(&task->answerbox, 0);
call = ipc_wait_for_call(&task->answerbox, SYNCH_NO_TIMEOUT, SYNCH_BLOCKING);
ASSERT((call->flags & IPC_CALL_ANSWERED) || (call->flags & IPC_CALL_NOTIF));
ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC));