Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2659 → Rev 2660

/trunk/uspace/app/tester/devmap/devmap1.c
49,8 → 49,9
ipc_call_t call;
int retval;
printf("connected: method=%u arg1=%u, arg2=%u arg3=%u.\n", IPC_GET_METHOD(*icall),
IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall), IPC_GET_ARG3(*icall));
printf("connected: method=%u arg1=%u, arg2=%u arg3=%u.\n",
IPC_GET_METHOD(*icall), IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall),
IPC_GET_ARG3(*icall));
 
printf("driver_client_connection.\n");
ipc_answer_0(iid, EOK);
59,14 → 60,16
while (1) {
callid = async_get_call(&call);
retval = EOK;
printf("method=%u arg1=%u, arg2=%u arg3=%u.\n", IPC_GET_METHOD(call),
IPC_GET_ARG1(call), IPC_GET_ARG2(call), IPC_GET_ARG3(call));
printf("method=%u arg1=%u, arg2=%u arg3=%u.\n",
IPC_GET_METHOD(call), IPC_GET_ARG1(call),
IPC_GET_ARG2(call), IPC_GET_ARG3(call));
switch (IPC_GET_METHOD(call)) {
case IPC_M_PHONE_HUNGUP:
/* TODO: Handle hangup */
return;
default:
printf("Unknown device method %u.\n", IPC_GET_METHOD(call));
printf("Unknown device method %u.\n",
IPC_GET_METHOD(call));
retval = ENOENT;
}
ipc_answer_0(callid, retval);
81,12 → 84,12
 
handle = (int)arg;
 
device_phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, \
DEVMAP_CONNECT_TO_DEVICE, handle);
device_phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
DEVMAP_CONNECT_TO_DEVICE, handle);
 
if (device_phone < 0) {
printf("Failed to connect to devmap as client (handle = %u).\n",
handle);
printf("Failed to connect to devmap as client (handle = %u).\n",
handle);
return -1;
}
/*
129,18 → 132,17
int phone;
ipcarg_t callback_phonehash;
 
phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
DEVMAP_DRIVER, 0);
phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_DRIVER, 0);
 
while (phone < 0) {
usleep(100000);
phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
DEVMAP_DRIVER, 0);
DEVMAP_DRIVER, 0);
}
req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
 
retval = ipc_data_send(phone, (char *)name, strlen(name) + 1);
retval = ipc_data_write_send(phone, (char *)name, strlen(name) + 1);
 
if (retval != EOK) {
async_wait_for(req, NULL);
170,9 → 172,10
aid_t req;
ipc_call_t answer;
 
req = async_send_2(driver_phone, DEVMAP_DEVICE_GET_HANDLE, 0, 0, &answer);
req = async_send_2(driver_phone, DEVMAP_DEVICE_GET_HANDLE, 0, 0,
&answer);
 
retval = ipc_data_send(driver_phone, name, strlen(name) + 1);
retval = ipc_data_write_send(driver_phone, name, strlen(name) + 1);
 
if (retval != EOK) {
printf("Failed to send device name '%s'.\n", name);
191,7 → 194,8
if (NULL != handle) {
*handle = (int) IPC_GET_ARG1(answer);
}
printf("Device '%s' has handle %u.\n", name, (int) IPC_GET_ARG1(answer));
printf("Device '%s' has handle %u.\n", name,
(int) IPC_GET_ARG1(answer));
} else {
printf("Failed to get handle for device '%s'.\n", name);
}
212,7 → 216,8
 
req = async_send_2(driver_phone, DEVMAP_DEVICE_REGISTER, 0, 0, &answer);
 
retval = ipc_data_send(driver_phone, (char *)name, strlen(name) + 1);
retval = ipc_data_write_send(driver_phone, (char *)name,
strlen(name) + 1);
 
if (retval != EOK) {
printf("Failed to send device name '%s'.\n", name);
231,7 → 236,8
if (NULL != handle) {
*handle = (int) IPC_GET_ARG1(answer);
}
printf("Device registered with handle %u.\n", (int) IPC_GET_ARG1(answer));
printf("Device registered with handle %u.\n",
(int) IPC_GET_ARG1(answer));
}
 
return retval;
/trunk/uspace/app/tester/vfs/vfs1.c
53,11 → 53,11
ipcarg_t rc;
aid_t req;
req = async_send_1(vfs_phone, VFS_MOUNT, TMPFS_DEVHANDLE, NULL);
if (ipc_data_send(vfs_phone, fs_name, strlen(fs_name)) != EOK) {
if (ipc_data_write_send(vfs_phone, fs_name, strlen(fs_name)) != EOK) {
async_wait_for(req, &rc);
return "Could not send fs_name to VFS.\n";
}
if (ipc_data_send(vfs_phone, mp, strlen(mp)) != EOK) {
if (ipc_data_write_send(vfs_phone, mp, strlen(mp)) != EOK) {
async_wait_for(req, &rc);
return "Could not send mp to VFS.\n";
}
70,7 → 70,7
char *path = "/dir2/file2";
ipc_call_t answer;
req = async_send_2(vfs_phone, VFS_OPEN, 0, 0, &answer);
if (ipc_data_send(vfs_phone, path, strlen(path)) != EOK) {
if (ipc_data_write_send(vfs_phone, path, strlen(path)) != EOK) {
async_wait_for(req, &rc);
return "Could not send path to VFS.\n";
}
/trunk/uspace/lib/libfs/libfs.c
71,7 → 71,7
/*
* Send our VFS info structure to VFS.
*/
int rc = ipc_data_send(vfs_phone, info, sizeof(*info));
int rc = ipc_data_write_send(vfs_phone, info, sizeof(*info));
if (rc != EOK) {
async_wait_for(req, NULL);
return rc;
/trunk/uspace/lib/libc/include/ipc/ipc.h
260,9 → 260,11
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, ipcarg_t arg2, int mode);
extern int ipc_data_send(int phoneid, void *src, size_t size);
extern int ipc_data_receive(ipc_callid_t *callid, void **dst, size_t *size);
extern ipcarg_t ipc_data_deliver(ipc_callid_t callid, void *dst, size_t size);
extern int ipc_data_write_send(int phoneid, void *src, size_t size);
extern int ipc_data_write_receive(ipc_callid_t *callid, void **dst,
size_t *size);
extern ipcarg_t ipc_data_write_deliver(ipc_callid_t callid, void *dst,
size_t size);
 
#endif
 
/trunk/uspace/lib/libc/generic/ipc.c
666,7 → 666,7
arg2, mode);
}
 
/** Wrapper for making IPC_M_DATA_SEND calls.
/** Wrapper for making IPC_M_DATA_WRITE calls.
*
* @param phoneid Phone that will be used to contact the receiving side.
* @param src Address of the beginning of the source buffer.
674,20 → 674,20
*
* @return Zero on success or a negative error code from errno.h.
*/
int ipc_data_send(int phoneid, void *src, size_t size)
int ipc_data_write_send(int phoneid, void *src, size_t size)
{
return ipc_call_sync_3_0(phoneid, IPC_M_DATA_SEND, 0, (ipcarg_t) src,
return ipc_call_sync_3_0(phoneid, IPC_M_DATA_WRITE, 0, (ipcarg_t) src,
(ipcarg_t) size);
}
 
/** Wrapper for receiving the IPC_M_DATA_SEND calls.
/** Wrapper for receiving the IPC_M_DATA_WRITE calls.
*
* This wrapper only makes it more comfortable to receive IPC_M_DATA_SEND calls
* This wrapper only makes it more comfortable to receive IPC_M_DATA_WRITE 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.
*
* @param callid Storage where the hash of the IPC_M_DATA_SEND call will
* @param callid Storage where the hash of the IPC_M_DATA_WRITE call will
* be stored.
* @param dst Storage where the suggested destination address will
* be stored. May be NULL.
696,7 → 696,7
*
* @return Non-zero on success, zero on failure.
*/
int ipc_data_receive(ipc_callid_t *callid, void **dst, size_t *size)
int ipc_data_write_receive(ipc_callid_t *callid, void **dst, size_t *size)
{
ipc_call_t data;
703,7 → 703,7
assert(callid);
 
*callid = async_get_call(&data);
if (IPC_GET_METHOD(data) != IPC_M_DATA_SEND)
if (IPC_GET_METHOD(data) != IPC_M_DATA_WRITE)
return 0;
if (dst)
*dst = (void *) IPC_GET_ARG1(data);
712,18 → 712,18
return 1;
}
 
/** Wrapper for answering the IPC_M_DATA_SEND calls.
/** Wrapper for answering the IPC_M_DATA_WRITE calls.
*
* This wrapper only makes it more comfortable to answer IPC_M_DATA_SEND calls
* This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE calls
* so that the user doesn't have to remember the meaning of each IPC argument.
*
* @param callid Hash of the IPC_M_DATA_SEND call to answer.
* @param dst Final destination address for the IPC_M_DATA_SEND call.
* @param size Final size for the IPC_M_DATA_SEND call.
* @param callid Hash of the IPC_M_DATA_WRITE call to answer.
* @param dst Final destination address for the IPC_M_DATA_WRITE call.
* @param size Final size for the IPC_M_DATA_WRITE call.
*
* @return Zero on success or a value from @ref errno.h on failure.
*/
ipcarg_t ipc_data_deliver(ipc_callid_t callid, void *dst, size_t size)
ipcarg_t ipc_data_write_deliver(ipc_callid_t callid, void *dst, size_t size)
{
return ipc_answer_3(callid, EOK, (ipcarg_t) dst, 0, (ipcarg_t) size);
}
/trunk/uspace/srv/devmap/devmap.c
202,7 → 202,7
/*
* Get driver name
*/
if (!ipc_data_receive(&callid, NULL, &name_size)) {
if (!ipc_data_write_receive(&callid, NULL, &name_size)) {
printf("Unexpected request.\n");
free(driver);
ipc_answer_0(callid, EREFUSED);
233,7 → 233,7
/*
* Send confirmation to sender and get data into buffer.
*/
if (EOK != ipc_data_deliver(callid, driver->name, name_size)) {
if (EOK != ipc_data_write_deliver(callid, driver->name, name_size)) {
printf("Cannot read driver name.\n");
free(driver->name);
free(driver);
368,7 → 368,7
}
/* Get device name */
if (!ipc_data_receive(&callid, NULL, &size)) {
if (!ipc_data_write_receive(&callid, NULL, &size)) {
free(device);
printf("Cannot read device name.\n");
ipc_answer_0(iid, EREFUSED);
394,7 → 394,7
return;
}
ipc_data_deliver(callid, device->name, size);
ipc_data_write_deliver(callid, device->name, size);
device->name[size] = 0;
 
list_initialize(&(device->devices));
489,7 → 489,7
* Wait for incoming message with device name (but do not
* read the name itself until the buffer is allocated).
*/
if (!ipc_data_receive(&callid, NULL, &name_size)) {
if (!ipc_data_write_receive(&callid, NULL, &name_size)) {
ipc_answer_0(callid, EREFUSED);
ipc_answer_0(iid, EREFUSED);
return;
513,7 → 513,7
/*
* Send confirmation to sender and get data into buffer.
*/
if (EOK != (retval = ipc_data_deliver(callid, name, name_size))) {
if (EOK != (retval = ipc_data_write_deliver(callid, name, name_size))) {
ipc_answer_0(iid, EREFUSED);
return;
}
566,7 → 566,7
we have no channel from DEVMAP to client ->
sending must be initiated by client
 
int rc = ipc_data_send(phone, device->name, name_size);
int rc = ipc_data_write_send(phone, device->name, name_size);
if (rc != EOK) {
async_wait_for(req, NULL);
return rc;
/trunk/uspace/srv/vfs/vfs_open.c
61,7 → 61,7
 
ipc_callid_t callid;
 
if (!ipc_data_receive(&callid, NULL, &size)) {
if (!ipc_data_write_receive(&callid, NULL, &size)) {
ipc_answer_0(callid, EINVAL);
ipc_answer_0(rid, EINVAL);
return;
82,7 → 82,7
}
 
int rc;
if ((rc = ipc_data_deliver(callid, path, size))) {
if ((rc = ipc_data_write_deliver(callid, path, size))) {
ipc_answer_0(rid, rc);
free(path);
return;
/trunk/uspace/srv/vfs/vfs_mount.c
86,7 → 86,7
* Now, we expect the client to send us data with the name of the file
* system.
*/
if (!ipc_data_receive(&callid, NULL, &size)) {
if (!ipc_data_write_receive(&callid, NULL, &size)) {
ipc_answer_0(callid, EINVAL);
ipc_answer_0(rid, EINVAL);
return;
106,7 → 106,7
* Deliver the file system name.
*/
char fs_name[FS_NAME_MAXLEN + 1];
(void) ipc_data_deliver(callid, fs_name, size);
(void) ipc_data_write_deliver(callid, fs_name, size);
fs_name[size] = '\0';
/*
122,7 → 122,7
/*
* Now, we want the client to send us the mount point.
*/
if (!ipc_data_receive(&callid, NULL, &size)) {
if (!ipc_data_write_receive(&callid, NULL, &size)) {
ipc_answer_0(callid, EINVAL);
ipc_answer_0(rid, EINVAL);
return;
150,7 → 150,7
/*
* Deliver the mount point.
*/
(void) ipc_data_deliver(callid, buf, size);
(void) ipc_data_write_deliver(callid, buf, size);
 
/*
* Lookup the root node of the filesystem being mounted.
/trunk/uspace/srv/vfs/vfs_register.c
164,7 → 164,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_receive(&callid, NULL, &size)) {
if (!ipc_data_write_receive(&callid, NULL, &size)) {
/*
* The client doesn't obey the same protocol as we do.
*/
205,7 → 205,7
link_initialize(&fs_info->fs_link);
futex_initialize(&fs_info->phone_futex, 1);
rc = ipc_data_deliver(callid, &fs_info->vfs_info, size);
rc = ipc_data_write_deliver(callid, &fs_info->vfs_info, size);
if (rc != EOK) {
dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n",
rc);