Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2614 → Rev 2615

/trunk/uspace/app/tester/ipc/send_sync.c
29,6 → 29,7
#include <stdio.h>
#include <unistd.h>
#include "../tester.h"
#include <ipc/ipc.h>
 
char * test_send_sync(bool quiet)
{
44,7 → 45,7
phoneid = c - '0';
printf("Sending msg...");
res = ipc_call_sync_2(phoneid, 2000, 0, 0, NULL, NULL);
res = ipc_call_sync_0_0(phoneid, 2000);
printf("done: %d\n", res);
return NULL;
/trunk/uspace/app/klog/klog.c
63,9 → 63,8
printf("Kernel console output.\n");
mapping = as_get_mappable_page(PAGE_SIZE);
res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV,
(sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_KLOG,
NULL, NULL, NULL);
res = ipc_call_sync_3_0(PHONE_NS, IPC_M_AS_AREA_RECV,
(sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_KLOG);
if (res) {
printf("Failed to initialize klog memarea\n");
_exit(1);
/trunk/uspace/lib/libc/include/ipc/ipc.h
51,16 → 51,139
typedef void (* ipc_async_callback_t)(void *private, int retval,
ipc_call_t *data);
 
#define ipc_call_sync_2(phoneid, method, arg1, arg2, res1, res2) \
ipc_call_sync_3((phoneid), (method), (arg1), (arg2), 0, (res1), \
(res2), 0)
extern int ipc_call_sync_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
/*
* User-friendly wrappers for ipc_call_sync_fast() and ipc_call_sync_slow().
* They are in the form ipc_call_sync_m_n(), where m denotes the number of
* arguments of payload and n denotes number of return values. Whenever
* possible, the fast version is used.
*/
#define ipc_call_sync_0_0(phoneid, method) \
ipc_call_sync_fast((phoneid), (method), 0, 0, 0, 0, 0, 0, 0, 0)
#define ipc_call_sync_0_1(phoneid, method, res1) \
ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), 0, 0, 0, 0)
#define ipc_call_sync_0_2(phoneid, method, res1, res2) \
ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), 0, 0, 0)
#define ipc_call_sync_0_3(phoneid, method, res1, res2, res3) \
ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
0, 0)
#define ipc_call_sync_0_4(phoneid, method, res1, res2, res3, res4) \
ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
(res4), 0)
#define ipc_call_sync_0_5(phoneid, method, res1, res2, res3, res4, res5) \
ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
(res4), (res5))
#define ipc_call_sync_1_0(phoneid, method, arg1) \
ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, 0, 0, 0, 0, 0)
#define ipc_call_sync_1_1(phoneid, method, arg1, res1) \
ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), 0, 0, 0, 0)
#define ipc_call_sync_1_2(phoneid, method, arg1, res1, res2) \
ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), 0, \
0, 0)
#define ipc_call_sync_1_3(phoneid, method, arg1, res1, res2, res3) \
ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
(res3), 0, 0)
#define ipc_call_sync_1_4(phoneid, method, arg1, res1, res2, res3, res4) \
ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
(res3), (res4), 0)
#define ipc_call_sync_1_5(phoneid, method, arg1, res1, res2, res3, res4, \
res5) \
ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
(res3), (res4), (res5))
#define ipc_call_sync_2_0(phoneid, method, arg1, arg2) \
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, 0, 0, 0, \
0, 0)
#define ipc_call_sync_2_1(phoneid, method, arg1, arg2, res1) \
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), 0, 0, \
0, 0)
#define ipc_call_sync_2_2(phoneid, method, arg1, arg2, res1, res2) \
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
(res2), 0, 0, 0)
#define ipc_call_sync_2_3(phoneid, method, arg1, arg2, res1, res2, res3) \
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
(res2), (res3), 0, 0)
#define ipc_call_sync_2_4(phoneid, method, arg1, arg2, res1, res2, res3, \
res4) \
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
(res2), (res3), (res4), 0)
#define ipc_call_sync_2_5(phoneid, method, arg1, arg2, res1, res2, res3, \
res4, res5)\
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
(res2), (res3), (res4), (res5))
#define ipc_call_sync_3_0(phoneid, method, arg1, arg2, arg3) \
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, 0, 0, \
0, 0)
#define ipc_call_sync_3_1(phoneid, method, arg1, arg2, arg3, res1) \
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
0, 0, 0, 0)
#define ipc_call_sync_3_2(phoneid, method, arg1, arg2, arg3, res1, res2) \
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
(res2), 0, 0, 0)
#define ipc_call_sync_3_3(phoneid, method, arg1, arg2, arg3, res1, res2, \
res3) \
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
(res1), (res2), (res3), 0, 0)
#define ipc_call_sync_3_4(phoneid, method, arg1, arg2, arg3, res1, res2, \
res3, res4) \
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
(res1), (res2), (res3), (res4), 0)
#define ipc_call_sync_3_5(phoneid, method, arg1, arg2, arg3, res1, res2, \
res3, res4, res5) \
ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
(res1), (res2), (res3), (res4), (res5))
#define ipc_call_sync_4_0(phoneid, method, arg1, arg2, arg3, arg4) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
0, 0, 0, 0, 0)
#define ipc_call_sync_4_1(phoneid, method, arg1, arg2, arg3, arg4, res1) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
(res1), 0, 0, 0, 0)
#define ipc_call_sync_4_2(phoneid, method, arg1, arg2, arg3, arg4, res1, res2) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
(res1), (res2), 0, 0, 0)
#define ipc_call_sync_4_3(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
res3) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
(arg4), (res1), (res2), (res3), 0, 0)
#define ipc_call_sync_4_4(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
res3, res4) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
(arg4), (res1), (res2), (res3), (res4), 0)
#define ipc_call_sync_4_5(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
res3, res4, res5) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
(arg4), (res1), (res2), (res3), (res4), (res5))
#define ipc_call_sync_5_0(phoneid, method, arg1, arg2, arg3, arg4, arg5) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
(arg5), 0, 0, 0, 0, 0)
#define ipc_call_sync_5_1(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
(arg5), (res1), 0, 0, 0, 0)
#define ipc_call_sync_5_2(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
res2) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
(arg4), (arg5), (res1), (res2), 0, 0, 0)
#define ipc_call_sync_5_3(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
res2, res3) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
(arg4), (arg5), (res1), (res2), (res3), 0, 0)
#define ipc_call_sync_5_4(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
res2, res3, res4) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
(arg4), (arg5), (res1), (res2), (res3), (res4), 0)
#define ipc_call_sync_5_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
res2, res3, res4, res5) \
ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
(arg4), (arg5), (res1), (res2), (res3), (res4), (res5))
 
extern int ipc_call_sync_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t arg2, ipcarg_t arg3, ipcarg_t *result1, ipcarg_t *result2,
ipcarg_t *result3);
ipcarg_t *result3, ipcarg_t *result4, ipcarg_t *result5);
 
extern int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t *result);
extern int ipc_call_sync_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5,
ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3, ipcarg_t *result4,
ipcarg_t *result5);
 
 
extern ipc_callid_t ipc_wait_cycle(ipc_call_t *call, uint32_t usec, int flags);
extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *data, uint32_t usec);
static inline ipc_callid_t ipc_wait_for_call(ipc_call_t *data)
/trunk/uspace/lib/libc/generic/time.c
141,9 → 141,9
if (!ktime) {
mapping = as_get_mappable_page(PAGE_SIZE);
/* Get the mapping of kernel clock */
res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV,
res = ipc_call_sync_3_2(PHONE_NS, IPC_M_AS_AREA_RECV,
(sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL,
&rights, NULL);
&rights);
if (res) {
printf("Failed to initialize timeofday memarea\n");
_exit(1);
/trunk/uspace/lib/libc/generic/ipc.c
84,32 → 84,51
 
/** Make a fast synchronous call.
*
* Only one payload argument can be passed using this function. However, this
* function is faster than the generic ipc_call_sync_3().
* Only three payload arguments can be passed using this function. However, this
* function is faster than the generic ipc_call_sync_slow() because the payload
* is passed directly in registers.
*
* @param phoneid Phone handle for the call.
* @param method Requested method.
* @param arg1 Service-defined payload argument.
* @param result If non-NULL, the return ARG1 will be stored there.
* @param arg2 Service-defined payload argument.
* @param arg3 Service-defined payload argument.
* @param result1 If non-NULL, the return ARG1 will be stored there.
* @param result2 If non-NULL, the return ARG2 will be stored there.
* @param result3 If non-NULL, the return ARG3 will be stored there.
* @param result4 If non-NULL, the return ARG4 will be stored there.
* @param result5 If non-NULL, the return ARG5 will be stored there.
*
* @return Negative values represent errors returned by IPC.
* Otherwise the RETVAL of the answer is returned.
*/
int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t *result)
int
ipc_call_sync_fast(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
ipcarg_t arg3, ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3,
ipcarg_t *result4, ipcarg_t *result5)
{
ipc_call_t resdata;
int callres;
callres = __SYSCALL4(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1,
(sysarg_t) &resdata);
callres = __SYSCALL6(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1,
arg2, arg3, (sysarg_t) &resdata);
if (callres)
return callres;
if (result)
*result = IPC_GET_ARG1(resdata);
if (result1)
*result1 = IPC_GET_ARG1(resdata);
if (result2)
*result2 = IPC_GET_ARG2(resdata);
if (result3)
*result3 = IPC_GET_ARG3(resdata);
if (result4)
*result4 = IPC_GET_ARG4(resdata);
if (result5)
*result5 = IPC_GET_ARG5(resdata);
 
return IPC_GET_RETVAL(resdata);
}
 
/** Make a synchronous call transmitting 3 arguments of payload.
/** Make a synchronous call transmitting 5 arguments of payload.
*
* @param phoneid Phone handle for the call.
* @param method Requested method.
116,15 → 135,21
* @param arg1 Service-defined payload argument.
* @param arg2 Service-defined payload argument.
* @param arg3 Service-defined payload argument.
* @param arg4 Service-defined payload argument.
* @param arg5 Service-defined payload argument.
* @param result1 If non-NULL, storage for the first return argument.
* @param result2 If non-NULL, storage for the second return argument.
* @param result3 If non-NULL, storage for the third return argument.
* @param result4 If non-NULL, storage for the fourth return argument.
* @param result5 If non-NULL, storage for the fifth return argument.
*
* @return Negative value means IPC error.
* Otherwise the RETVAL of the answer.
*/
int ipc_call_sync_3(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
ipcarg_t arg3, ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3)
int
ipc_call_sync_slow(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *result1,
ipcarg_t *result2, ipcarg_t *result3, ipcarg_t *result4, ipcarg_t *result5)
{
ipc_call_t data;
int callres;
133,8 → 158,10
IPC_SET_ARG1(data, arg1);
IPC_SET_ARG2(data, arg2);
IPC_SET_ARG3(data, arg3);
IPC_SET_ARG4(data, arg4);
IPC_SET_ARG5(data, arg5);
 
callres = __SYSCALL3(SYS_IPC_CALL_SYNC, phoneid, (sysarg_t) &data,
callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid, (sysarg_t) &data,
(sysarg_t) &data);
if (callres)
return callres;
145,6 → 172,11
*result2 = IPC_GET_ARG2(data);
if (result3)
*result3 = IPC_GET_ARG3(data);
if (result4)
*result4 = IPC_GET_ARG4(data);
if (result5)
*result5 = IPC_GET_ARG5(data);
 
return IPC_GET_RETVAL(data);
}
 
515,8 → 547,8
*/
int ipc_connect_to_me(int phoneid, int arg1, int arg2, ipcarg_t *phonehash)
{
return ipc_call_sync_3(phoneid, IPC_M_CONNECT_TO_ME, arg1, arg2, 0, 0,
0, phonehash);
return ipc_call_sync_2_3(phoneid, IPC_M_CONNECT_TO_ME, arg1, arg2,
NULL, NULL, phonehash);
}
 
/** Ask through phone for a new connection to some service.
532,8 → 564,8
ipcarg_t newphid;
int res;
 
res = ipc_call_sync_3(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, 0, 0, 0,
&newphid);
res = ipc_call_sync_2_3(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, NULL,
NULL, &newphid);
if (res)
return res;
return newphid;
605,8 → 637,8
*/
int ipc_data_send(int phoneid, void *src, size_t size)
{
return ipc_call_sync_3(phoneid, IPC_M_DATA_SEND, 0, (ipcarg_t) src,
(ipcarg_t) size, NULL, NULL, NULL);
return ipc_call_sync_3_0(phoneid, IPC_M_DATA_SEND, 0, (ipcarg_t) src,
(ipcarg_t) size);
}
 
/** Wrapper for receiving the IPC_M_DATA_SEND calls.
/trunk/uspace/srv/fs/fat/fat.c
157,8 → 157,8
/*
* Request sharing the Path Lookup Buffer with VFS.
*/
rc = ipc_call_sync_3(vfs_phone, IPC_M_AS_AREA_RECV, (ipcarg_t) plb_ro,
PLB_SIZE, 0, NULL, NULL, NULL);
rc = ipc_call_sync_2_0(vfs_phone, IPC_M_AS_AREA_RECV, (ipcarg_t) plb_ro,
PLB_SIZE);
if (rc) {
async_wait_for(req, NULL);
return rc;