/trunk/uspace/lib/libc/include/async.h |
---|
102,8 → 102,7 |
fid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid, |
ipc_call_t *call, |
void (*cthread)(ipc_callid_t,ipc_call_t *)); |
ipc_call_t *call, void (*cthread)(ipc_callid_t,ipc_call_t *)); |
void async_usleep(suseconds_t timeout); |
void async_create_manager(void); |
void async_destroy_manager(void); |
/trunk/uspace/lib/libc/include/ipc/ipc.h |
---|
74,8 → 74,7 |
extern ipcarg_t ipc_answer(ipc_callid_t callid, ipc_call_t *call); |
#define ipc_call_async(phoneid, method, arg1, private, callback, can_preempt) \ |
(ipc_call_async_2(phoneid, method, arg1, 0, private, callback, \ |
can_preempt)) |
(ipc_call_async_2(phoneid, method, arg1, 0, private, callback, can_preempt)) |
extern void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1, |
ipcarg_t arg2, void *private, ipc_async_callback_t callback, |
int can_preempt); |
90,10 → 89,10 |
extern int ipc_unregister_irq(int inr, int devno); |
extern int ipc_forward_fast(ipc_callid_t callid, int phoneid, int method, |
ipcarg_t arg1); |
extern int ipc_data_send_accept(ipc_callid_t *callid, ipc_call_t *call, |
void **dst, size_t *size); |
extern ipcarg_t ipc_data_send_answer(ipc_callid_t callid, ipc_call_t *call, |
extern int ipc_data_send(int phoneid, void *src, size_t size); |
extern int ipc_data_receive(ipc_callid_t *callid, ipc_call_t *call, void **dst, |
size_t *size); |
extern ipcarg_t ipc_data_deliver(ipc_callid_t callid, ipc_call_t *call, |
void *dst, size_t size); |
#endif |
/trunk/uspace/lib/libc/generic/ipc.c |
---|
515,8 → 515,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_3(phoneid, IPC_M_CONNECT_TO_ME, arg1, arg2, 0, 0, |
0, phonehash); |
} |
/** Ask through phone for a new connection to some service. |
532,7 → 532,7 |
ipcarg_t newphid; |
int res; |
res = ipc_call_sync_3(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, 0, 0, 0, |
res = ipc_call_sync_3(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, 0, 0, 0, |
&newphid); |
if (res) |
return res; |
595,9 → 595,23 |
return __SYSCALL4(SYS_IPC_FORWARD_FAST, callid, phoneid, method, arg1); |
} |
/** Wrapper for accepting the IPC_M_DATA_SEND calls. |
/** Wrapper for making IPC_M_DATA_SEND calls. |
* |
* This wrapper only makes it more comfortable to accept IPC_M_DATA_SEND calls |
* @param phoneid Phone that will be used to contact the receiving side. |
* @param src Address of the beginning of the source buffer. |
* @param size Size of the source buffer. |
* |
* @return Zero on success or a negative error code from errno.h. |
*/ |
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); |
} |
/** Wrapper for receiving the IPC_M_DATA_SEND calls. |
* |
* This wrapper only makes it more comfortable to receive IPC_M_DATA_SEND calls |
* so that the user doesn't have to remember the meaning of each IPC argument. |
* |
* So far, this wrapper is to be used from within a connection fibril. |
612,7 → 626,7 |
* |
* @return Non-zero on success, zero on failure. |
*/ |
int ipc_data_send_accept(ipc_callid_t *callid, ipc_call_t *call, void **dst, |
int ipc_data_receive(ipc_callid_t *callid, ipc_call_t *call, void **dst, |
size_t *size) |
{ |
assert(callid); |
640,7 → 654,8 |
* |
* @return Zero on success or a value from @ref errno.h on failure. |
*/ |
ipcarg_t ipc_data_send_answer(ipc_callid_t callid, ipc_call_t *call, void *dst, size_t size) |
ipcarg_t ipc_data_deliver(ipc_callid_t callid, ipc_call_t *call, void *dst, |
size_t size) |
{ |
IPC_SET_RETVAL(*call, EOK); |
IPC_SET_ARG1(*call, (ipcarg_t) dst); |
/trunk/uspace/srv/fs/fat/fat.c |
---|
38,6 → 38,7 |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
#include <async.h> |
#include <errno.h> |
#include <unistd.h> |
#include "../../vfs/vfs.h" |
58,6 → 59,20 |
} |
}; |
/* |
* This fibril processes request from the VFS server. |
*/ |
void fat_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
while (1) { |
ipc_callid_t callid; |
ipc_call_t call; |
callid = async_get_call(&call); |
ipc_answer_fast(callid, ENOTSUP, 0, 0); |
} |
} |
int main(int argc, char **argv) |
{ |
ipcarg_t vfs_phone; |
68,8 → 83,30 |
vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0); |
} |
/* TODO: start making calls according to the VFS protocol */ |
/* |
* Tell VFS that we are here and want to get registered. |
* We use the async framework because VFS will answer the request |
* out-of-order, when it knows that the operation succeeded or failed. |
*/ |
ipc_call_t answer; |
aid_t req = async_send_2(vfs_phone, VFS_REGISTER, 0, 0, &answer); |
/* |
* Send our VFS info structure to VFS. |
*/ |
int rc = ipc_data_send(vfs_phone, &fat_vfs_info, sizeof(fat_vfs_info)); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
return rc; |
} |
/* |
* Ask VFS for callback connection. |
*/ |
ipcarg_t phonehash; |
ipc_connect_to_me(vfs_phone, 0, 0, &phonehash); |
async_new_connection(phonehash, 0, NULL, fat_connection); |
return 0; |
} |
/trunk/uspace/srv/vfs/vfs.c |
---|
123,7 → 123,7 |
* The first call has to be IPC_M_DATA_SEND in which we receive the |
* VFS info structure from the client FS. |
*/ |
if (!ipc_data_send_accept(&callid, &call, NULL, &size)) { |
if (!ipc_data_receive(&callid, &call, NULL, &size)) { |
/* |
* The client doesn't obey the same protocol as we do. |
*/ |
158,7 → 158,7 |
} |
link_initialize(&fs_info->fs_link); |
rc = ipc_data_send_answer(callid, &call, &fs_info->vfs_info, size); |
rc = ipc_data_deliver(callid, &call, &fs_info->vfs_info, size); |
if (!rc) { |
free(fs_info); |
ipc_answer_fast(callid, rc, 0, 0); |