Changeset b74959bd in mainline for uspace/lib/libc
- Timestamp:
- 2007-11-20T21:33:32Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8498915
- Parents:
- 3209923
- Location:
- uspace/lib/libc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/async.c
r3209923 rb74959bd 76 76 * { 77 77 * if (want_refuse) { 78 * ipc_answer_ fast(icallid, ELIMIT, 0, 0);78 * ipc_answer_0(icallid, ELIMIT); 79 79 * return; 80 80 * } 81 * ipc_answer_ fast(icallid, EOK, 0, 0);81 * ipc_answer_0(icallid, EOK); 82 82 * 83 83 * callid = async_get_call(&call); 84 84 * handle_call(callid, call); 85 * ipc_answer_ fast(callid, 1, 2, 3);85 * ipc_answer_2(callid, 1, 2, 3); 86 86 * 87 87 * callid = async_get_call(&call); … … 396 396 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call) 397 397 { 398 ipc_answer_ fast(callid, ENOENT, 0, 0);398 ipc_answer_0(callid, ENOENT); 399 399 } 400 400 … … 441 441 if (msg->callid == FIBRIL_connection->close_callid) 442 442 close_answered = 1; 443 ipc_answer_ fast(msg->callid, EHANGUP, 0, 0);443 ipc_answer_0(msg->callid, EHANGUP); 444 444 free(msg); 445 445 } 446 446 if (FIBRIL_connection->close_callid) 447 ipc_answer_ fast(FIBRIL_connection->close_callid, 0, 0, 0);447 ipc_answer_0(FIBRIL_connection->close_callid, EOK); 448 448 449 449 return 0; … … 476 476 if (!conn) { 477 477 if (callid) 478 ipc_answer_ fast(callid, ENOMEM, 0, 0);478 ipc_answer_0(callid, ENOMEM); 479 479 return NULL; 480 480 } … … 492 492 free(conn); 493 493 if (callid) 494 ipc_answer_ fast(callid, ENOMEM, 0, 0);494 ipc_answer_0(callid, ENOMEM); 495 495 return NULL; 496 496 } … … 537 537 538 538 /* Unknown call from unknown phone - hang it up */ 539 ipc_answer_ fast(callid, EHANGUP, 0, 0);539 ipc_answer_0(callid, EHANGUP); 540 540 } 541 541 -
uspace/lib/libc/generic/ipc.c
r3209923 rb74959bd 376 376 /** Answer a received call - fast version. 377 377 * 378 * The fast answer makes use of passing retval and first twoarguments in379 * registers. If you need to return more, use the ipc_answer () instead.378 * The fast answer makes use of passing retval and first four arguments in 379 * registers. If you need to return more, use the ipc_answer_slow() instead. 380 380 * 381 381 * @param callid Hash of the call being answered. … … 383 383 * @param arg1 First return argument. 384 384 * @param arg2 Second return argument. 385 * @param arg3 Third return argument. 386 * @param arg4 Fourth return argument. 385 387 * 386 388 * @return Zero on success or a value from @ref errno.h on failure. 387 389 */ 388 390 ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1, 389 ipcarg_t arg2) 390 { 391 return __SYSCALL4(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2); 392 } 393 394 /** Answer a received call - full version. 391 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4) 392 { 393 return __SYSCALL6(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2, arg3, 394 arg4); 395 } 396 397 /** Answer a received call - slow full version. 395 398 * 396 399 * @param callid Hash of the call being answered. 397 * @param call Call structure with the answer. 398 * Must be already initialized by the responder. 400 * @param retval Return value. 401 * @param arg1 First return argument. 402 * @param arg2 Second return argument. 403 * @param arg3 Third return argument. 404 * @param arg4 Fourth return argument. 405 * @param arg5 Fifth return argument. 399 406 * 400 407 * @return Zero on success or a value from @ref errno.h on failure. 401 408 */ 402 ipcarg_t ipc_answer(ipc_callid_t callid, ipc_call_t *call) 403 { 404 return __SYSCALL2(SYS_IPC_ANSWER, callid, (sysarg_t) call); 409 ipcarg_t ipc_answer_slow(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1, 410 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5) 411 { 412 ipc_call_t data; 413 414 IPC_SET_RETVAL(data, retval); 415 IPC_SET_ARG1(data, arg1); 416 IPC_SET_ARG2(data, arg2); 417 IPC_SET_ARG3(data, arg3); 418 IPC_SET_ARG4(data, arg4); 419 IPC_SET_ARG5(data, arg5); 420 421 return __SYSCALL2(SYS_IPC_ANSWER_SLOW, callid, (sysarg_t) &data); 405 422 } 406 423 … … 659 676 * @param callid Storage where the hash of the IPC_M_DATA_SEND call will 660 677 * be stored. 661 * @param call Storage where the incoming call will be stored.662 678 * @param dst Storage where the suggested destination address will 663 679 * be stored. May be NULL. … … 667 683 * @return Non-zero on success, zero on failure. 668 684 */ 669 int ipc_data_receive(ipc_callid_t *callid, ipc_call_t *call, void **dst, 670 size_t *size) 671 { 685 int ipc_data_receive(ipc_callid_t *callid, void **dst, size_t *size) 686 { 687 ipc_call_t data; 688 672 689 assert(callid); 673 assert(call); 674 675 *callid = async_get_call(call); 676 if (IPC_GET_METHOD(*call) != IPC_M_DATA_SEND) 690 691 *callid = async_get_call(&data); 692 if (IPC_GET_METHOD(data) != IPC_M_DATA_SEND) 677 693 return 0; 678 694 if (dst) 679 *dst = (void *) IPC_GET_ARG1( *call);695 *dst = (void *) IPC_GET_ARG1(data); 680 696 if (size) 681 *size = (size_t) IPC_GET_ARG3( *call);697 *size = (size_t) IPC_GET_ARG3(data); 682 698 return 1; 683 699 } … … 689 705 * 690 706 * @param callid Hash of the IPC_M_DATA_SEND call to answer. 691 * @param call Call structure with the request.692 707 * @param dst Final destination address for the IPC_M_DATA_SEND call. 693 708 * @param size Final size for the IPC_M_DATA_SEND call. … … 695 710 * @return Zero on success or a value from @ref errno.h on failure. 696 711 */ 697 ipcarg_t ipc_data_deliver(ipc_callid_t callid, ipc_call_t *call, void *dst, 698 size_t size) 699 { 700 IPC_SET_RETVAL(*call, EOK); 701 IPC_SET_ARG1(*call, (ipcarg_t) dst); 702 IPC_SET_ARG3(*call, (ipcarg_t) size); 703 return ipc_answer(callid, call); 712 ipcarg_t ipc_data_deliver(ipc_callid_t callid, void *dst, size_t size) 713 { 714 return ipc_answer_3(callid, EOK, (ipcarg_t) dst, 0, (ipcarg_t) size); 704 715 } 705 716 -
uspace/lib/libc/include/ipc/ipc.h
r3209923 rb74959bd 191 191 extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *data); 192 192 193 #define ipc_answer_fast_0(callid, retval) \ 194 ipc_answer_fast((callid), (retval), 0, 0) 195 #define ipc_answer_fast_1(callid, retval, arg1) \ 196 ipc_answer_fast((callid), (retval), (arg1), 0) 193 /* 194 * User-friendly wrappers for ipc_answer_fast() and ipc_answer_slow(). 195 * They are in the form of ipc_answer_m(), where m is the number of return 196 * arguments. The macros decide between the fast and the slow version according 197 * to m. 198 */ 199 #define ipc_answer_0(callid, retval) \ 200 ipc_answer_fast((callid), (retval), 0, 0, 0, 0) 201 #define ipc_answer_1(callid, retval, arg1) \ 202 ipc_answer_fast((callid), (retval), (arg1), 0, 0, 0) 203 #define ipc_answer_2(callid, retval, arg1, arg2) \ 204 ipc_answer_fast((callid), (retval), (arg1), (arg2), 0, 0) 205 #define ipc_answer_3(callid, retval, arg1, arg2, arg3) \ 206 ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), 0) 207 #define ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4) \ 208 ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), (arg4)) 209 #define ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5) \ 210 ipc_answer_slow((callid), (retval), (arg1), (arg2), (arg3), (arg4), (arg5)) 211 197 212 extern ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval, 198 ipcarg_t arg1, ipcarg_t arg2); 199 extern ipcarg_t ipc_answer(ipc_callid_t callid, ipc_call_t *call); 213 ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4); 214 extern ipcarg_t ipc_answer_slow(ipc_callid_t callid, ipcarg_t retval, 215 ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5); 200 216 201 217 /* … … 245 261 ipcarg_t arg1); 246 262 extern int ipc_data_send(int phoneid, void *src, size_t size); 247 extern int ipc_data_receive(ipc_callid_t *callid, ipc_call_t *call, void **dst, 248 size_t *size); 249 extern ipcarg_t ipc_data_deliver(ipc_callid_t callid, ipc_call_t *call, 250 void *dst, size_t size); 263 extern int ipc_data_receive(ipc_callid_t *callid, void **dst, size_t *size); 264 extern ipcarg_t ipc_data_deliver(ipc_callid_t callid, void *dst, size_t size); 251 265 252 266 #endif
Note:
See TracChangeset
for help on using the changeset viewer.