Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async.c

    r6a5d05b r4d6629f  
    7777 *   }
    7878 *
    79  *   port_handler(ichandle, *icall)
     79 *   port_handler(icallid, *icall)
    8080 *   {
    8181 *     if (want_refuse) {
    82  *       async_answer_0(ichandle, ELIMIT);
     82 *       async_answer_0(icallid, ELIMIT);
    8383 *       return;
    8484 *     }
    85  *     async_answer_0(ichandle, EOK);
    86  *
    87  *     chandle = async_get_call(&call);
    88  *     somehow_handle_the_call(chandle, call);
    89  *     async_answer_2(chandle, 1, 2, 3);
    90  *
    91  *     chandle = async_get_call(&call);
     85 *     async_answer_0(icallid, EOK);
     86 *
     87 *     callid = async_get_call(&call);
     88 *     somehow_handle_the_call(callid, call);
     89 *     async_answer_2(callid, 1, 2, 3);
     90 *
     91 *     callid = async_get_call(&call);
    9292 *     ...
    9393 *   }
     
    106106#include <fibril.h>
    107107#include <adt/hash_table.h>
    108 #include <adt/hash.h>
    109108#include <adt/list.h>
    110109#include <assert.h>
     
    113112#include <libarch/barrier.h>
    114113#include <stdbool.h>
    115 #include <stdlib.h>
     114#include <malloc.h>
    116115#include <mem.h>
    117116#include <stdlib.h>
     
    185184        link_t link;
    186185       
    187         cap_handle_t chandle;
     186        ipc_callid_t callid;
    188187        ipc_call_t call;
    189188} msg_t;
     
    205204        ipc_call_t *dataptr;
    206205       
    207         int retval;
     206        sysarg_t retval;
    208207} amsg_t;
    209208
     
    237236       
    238237        /** Identification of the opening call. */
    239         cap_handle_t chandle;
     238        ipc_callid_t callid;
    240239       
    241240        /** Call data of the opening call. */
     
    243242       
    244243        /** Identification of the closing call. */
    245         cap_handle_t close_chandle;
     244        ipc_callid_t close_callid;
    246245       
    247246        /** Fibril function that will be used to handle the connection. */
     
    332331                msg->destroyed = false;
    333332                msg->dataptr = NULL;
    334                 msg->retval = EINVAL;
     333                msg->retval = (sysarg_t) EINVAL;
    335334                awaiter_initialize(&msg->wdata);
    336335        }
     
    374373/** Default fallback fibril function.
    375374 *
    376  * This fallback fibril function gets called on incomming connections that do
    377  * not have a specific handler defined.
    378  *
    379  * @param chandle  Handle of the incoming call.
    380  * @param call     Data of the incoming call.
    381  * @param arg      Local argument
    382  *
    383  */
    384 static void default_fallback_port_handler(cap_handle_t chandle,
    385     ipc_call_t *call, void *arg)
    386 {
    387         ipc_answer_0(chandle, ENOENT);
     375 * This fallback fibril function gets called on incomming
     376 * connections that do not have a specific handler defined.
     377 *
     378 * @param callid Hash of the incoming call.
     379 * @param call   Data of the incoming call.
     380 * @param arg    Local argument
     381 *
     382 */
     383static void default_fallback_port_handler(ipc_callid_t callid, ipc_call_t *call,
     384    void *arg)
     385{
     386        ipc_answer_0(callid, ENOENT);
    388387}
    389388
     
    588587};
    589588
    590 typedef struct {
    591         task_id_t task_id;
    592         sysarg_t phone_hash;
    593 } conn_key_t;
    594 
    595 /** Compute hash into the connection hash table
    596  *
    597  * The hash is based on the source task ID and the source phone hash. The task
    598  * ID is included in the hash because a phone hash alone might not be unique
    599  * while we still track connections for killed tasks due to kernel's recycling
    600  * of phone structures.
    601  *
    602  * @param key Pointer to the connection key structure.
     589/** Compute hash into the connection hash table based on the source phone hash.
     590 *
     591 * @param key Pointer to source phone hash.
    603592 *
    604593 * @return Index into the connection hash table.
     
    607596static size_t conn_key_hash(void *key)
    608597{
    609         conn_key_t *ck = (conn_key_t *) key;
    610 
    611         size_t hash = 0;
    612         hash = hash_combine(hash, LOWER32(ck->task_id));
    613         hash = hash_combine(hash, UPPER32(ck->task_id));
    614         hash = hash_combine(hash, ck->phone_hash);
    615         return hash;
     598        sysarg_t in_phone_hash = *(sysarg_t *) key;
     599        return in_phone_hash;
    616600}
    617601
     
    619603{
    620604        connection_t *conn = hash_table_get_inst(item, connection_t, link);
    621         return conn_key_hash(&(conn_key_t){
    622                 .task_id = conn->in_task_id,
    623                 .phone_hash = conn->in_phone_hash
    624         });
     605        return conn_key_hash(&conn->in_phone_hash);
    625606}
    626607
    627608static bool conn_key_equal(void *key, const ht_link_t *item)
    628609{
    629         conn_key_t *ck = (conn_key_t *) key;
     610        sysarg_t in_phone_hash = *(sysarg_t *) key;
    630611        connection_t *conn = hash_table_get_inst(item, connection_t, link);
    631         return ((ck->task_id == conn->in_task_id) &&
    632             (ck->phone_hash == conn->in_phone_hash));
     612        return (in_phone_hash == conn->in_phone_hash);
    633613}
    634614
     
    715695        client_t *client = async_client_get(fibril_connection->in_task_id, true);
    716696        if (!client) {
    717                 ipc_answer_0(fibril_connection->chandle, ENOMEM);
     697                ipc_answer_0(fibril_connection->callid, ENOMEM);
    718698                return 0;
    719699        }
     
    724704         * Call the connection handler function.
    725705         */
    726         fibril_connection->handler(fibril_connection->chandle,
     706        fibril_connection->handler(fibril_connection->callid,
    727707            &fibril_connection->call, fibril_connection->data);
    728708       
     
    736716         */
    737717        futex_down(&async_futex);
    738         hash_table_remove(&conn_hash_table, &(conn_key_t){
    739                 .task_id = fibril_connection->in_task_id,
    740                 .phone_hash = fibril_connection->in_phone_hash
    741         });
     718        hash_table_remove(&conn_hash_table, &fibril_connection->in_phone_hash);
    742719        futex_up(&async_futex);
    743720       
     
    751728               
    752729                list_remove(&msg->link);
    753                 ipc_answer_0(msg->chandle, EHANGUP);
     730                ipc_answer_0(msg->callid, EHANGUP);
    754731                free(msg);
    755732        }
     
    759736         * i.e. IPC_M_PHONE_HUNGUP.
    760737         */
    761         if (fibril_connection->close_chandle)
    762                 ipc_answer_0(fibril_connection->close_chandle, EOK);
     738        if (fibril_connection->close_callid)
     739                ipc_answer_0(fibril_connection->close_callid, EOK);
    763740       
    764741        free(fibril_connection);
    765         return EOK;
     742        return 0;
    766743}
    767744
    768745/** Create a new fibril for a new connection.
    769746 *
    770  * Create new fibril for connection, fill in connection structures and insert it
    771  * into the hash table, so that later we can easily do routing of messages to
    772  * particular fibrils.
    773  *
    774  * @param in_task_id     Identification of the incoming connection.
    775  * @param in_phone_hash  Identification of the incoming connection.
    776  * @param chandle        Handle of the opening IPC_M_CONNECT_ME_TO call.
    777  *                       If chandle is CAP_NIL, the connection was opened by
    778  *                       accepting the IPC_M_CONNECT_TO_ME call and this
    779  *                       function is called directly by the server.
    780  * @param call           Call data of the opening call.
    781  * @param handler        Connection handler.
    782  * @param data           Client argument to pass to the connection handler.
    783  *
    784  * @return  New fibril id or NULL on failure.
     747 * Create new fibril for connection, fill in connection structures
     748 * and insert it into the hash table, so that later we can easily
     749 * do routing of messages to particular fibrils.
     750 *
     751 * @param in_task_id    Identification of the incoming connection.
     752 * @param in_phone_hash Identification of the incoming connection.
     753 * @param callid        Hash of the opening IPC_M_CONNECT_ME_TO call.
     754 *                      If callid is zero, the connection was opened by
     755 *                      accepting the IPC_M_CONNECT_TO_ME call and this
     756 *                      function is called directly by the server.
     757 * @param call          Call data of the opening call.
     758 * @param handler       Connection handler.
     759 * @param data          Client argument to pass to the connection handler.
     760 *
     761 * @return New fibril id or NULL on failure.
    785762 *
    786763 */
    787764static fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash,
    788     cap_handle_t chandle, ipc_call_t *call, async_port_handler_t handler,
     765    ipc_callid_t callid, ipc_call_t *call, async_port_handler_t handler,
    789766    void *data)
    790767{
    791768        connection_t *conn = malloc(sizeof(*conn));
    792769        if (!conn) {
    793                 if (chandle != CAP_NIL)
    794                         ipc_answer_0(chandle, ENOMEM);
     770                if (callid)
     771                        ipc_answer_0(callid, ENOMEM);
    795772               
    796773                return (uintptr_t) NULL;
     
    800777        conn->in_phone_hash = in_phone_hash;
    801778        list_initialize(&conn->msg_queue);
    802         conn->chandle = chandle;
    803         conn->close_chandle = CAP_NIL;
     779        conn->callid = callid;
     780        conn->close_callid = 0;
    804781        conn->handler = handler;
    805782        conn->data = data;
     
    815792                free(conn);
    816793               
    817                 if (chandle != CAP_NIL)
    818                         ipc_answer_0(chandle, ENOMEM);
     794                if (callid)
     795                        ipc_answer_0(callid, ENOMEM);
    819796               
    820797                return (uintptr_t) NULL;
     
    844821 * @param port_id ID of the newly created port.
    845822 *
    846  * @return Zero on success or an error code.
     823 * @return Zero on success or a negative error code.
    847824 *
    848825 */
     
    860837            &answer);
    861838       
    862         int ret;
     839        sysarg_t ret;
    863840        async_wait_for(req, &ret);
    864841        if (ret != EOK)
     
    892869       
    893870        fid_t fid = async_new_connection(answer.in_task_id, phone_hash,
    894             CAP_NIL, NULL, handler, data);
     871            0, NULL, handler, data);
    895872        if (fid == (uintptr_t) NULL)
    896873                return ENOMEM;
     
    961938 * timeouts are unregistered.
    962939 *
    963  * @param chandle  Handle of the incoming call.
    964  * @param call     Data of the incoming call.
     940 * @param callid Hash of the incoming call.
     941 * @param call   Data of the incoming call.
    965942 *
    966943 * @return False if the call doesn't match any connection.
     
    968945 *
    969946 */
    970 static bool route_call(cap_handle_t chandle, ipc_call_t *call)
     947static bool route_call(ipc_callid_t callid, ipc_call_t *call)
    971948{
    972949        assert(call);
     
    974951        futex_down(&async_futex);
    975952       
    976         ht_link_t *link = hash_table_find(&conn_hash_table, &(conn_key_t){
    977                 .task_id = call->in_task_id,
    978                 .phone_hash = call->in_phone_hash
    979         });
     953        ht_link_t *link = hash_table_find(&conn_hash_table, &call->in_phone_hash);
    980954        if (!link) {
    981955                futex_up(&async_futex);
     
    991965        }
    992966       
    993         msg->chandle = chandle;
     967        msg->callid = callid;
    994968        msg->call = *call;
    995969        list_append(&msg->link, &conn->msg_queue);
    996970       
    997971        if (IPC_GET_IMETHOD(*call) == IPC_M_PHONE_HUNGUP)
    998                 conn->close_chandle = chandle;
     972                conn->close_callid = callid;
    999973       
    1000974        /* If the connection fibril is waiting for an event, activate it */
     
    1017991/** Process notification.
    1018992 *
     993 * @param callid Hash of the incoming call.
    1019994 * @param call   Data of the incoming call.
    1020995 *
    1021996 */
    1022 static void process_notification(ipc_call_t *call)
     997static void process_notification(ipc_callid_t callid, ipc_call_t *call)
    1023998{
    1024999        async_notification_handler_t handler = NULL;
     
    10411016       
    10421017        if (handler)
    1043                 handler(call, data);
     1018                handler(callid, call, data);
    10441019}
    10451020
     
    10511026 * @param ucode   Top-half pseudocode handler.
    10521027 *
    1053  * @param[out] handle  IRQ capability handle on success.
    1054  *
    1055  * @return An error code.
     1028 * @return IRQ capability handle on success.
     1029 * @return Negative error code.
    10561030 *
    10571031 */
    10581032int async_irq_subscribe(int inr, async_notification_handler_t handler,
    1059     void *data, const irq_code_t *ucode, cap_handle_t *handle)
     1033    void *data, const irq_code_t *ucode)
    10601034{
    10611035        notification_t *notification =
     
    10771051        futex_up(&async_futex);
    10781052       
    1079         cap_handle_t cap;
    1080         int rc = ipc_irq_subscribe(inr, imethod, ucode, &cap);
    1081         if (rc == EOK && handle != NULL) {
    1082                 *handle = cap;
    1083         }
    1084         return rc;
     1053        return ipc_irq_subscribe(inr, imethod, ucode);
    10851054}
    10861055
     
    10891058 * @param cap     IRQ capability handle.
    10901059 *
    1091  * @return Zero on success or an error code.
     1060 * @return Zero on success or a negative error code.
    10921061 *
    10931062 */
     
    11061075 * @param data    Notification handler client data.
    11071076 *
    1108  * @return Zero on success or an error code.
     1077 * @return Zero on success or a negative error code.
    11091078 *
    11101079 */
     
    11391108 * @param data    Notification handler client data.
    11401109 *
    1141  * @return Zero on success or an error code.
     1110 * @return Zero on success or a negative error code.
    11421111 *
    11431112 */
     
    11921161/** Return new incoming message for the current (fibril-local) connection.
    11931162 *
    1194  * @param call   Storage where the incoming call data will be stored.
    1195  * @param usecs  Timeout in microseconds. Zero denotes no timeout.
    1196  *
    1197  * @return  If no timeout was specified, then a handle of the incoming call is
    1198  *          returned. If a timeout is specified, then a handle of the incoming
    1199  *          call is returned unless the timeout expires prior to receiving a
    1200  *          message. In that case zero CAP_NIL is returned.
    1201  */
    1202 cap_handle_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs)
     1163 * @param call  Storage where the incoming call data will be stored.
     1164 * @param usecs Timeout in microseconds. Zero denotes no timeout.
     1165 *
     1166 * @return If no timeout was specified, then a hash of the
     1167 *         incoming call is returned. If a timeout is specified,
     1168 *         then a hash of the incoming call is returned unless
     1169 *         the timeout expires prior to receiving a message. In
     1170 *         that case zero is returned.
     1171 *
     1172 */
     1173ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs)
    12031174{
    12041175        assert(call);
     
    12231194        /* If nothing in queue, wait until something arrives */
    12241195        while (list_empty(&conn->msg_queue)) {
    1225                 if (conn->close_chandle) {
     1196                if (conn->close_callid) {
    12261197                        /*
    12271198                         * Handle the case when the connection was already
     
    12341205                        IPC_SET_IMETHOD(*call, IPC_M_PHONE_HUNGUP);
    12351206                        futex_up(&async_futex);
    1236                         return conn->close_chandle;
     1207                        return conn->close_callid;
    12371208                }
    12381209               
     
    12591230                        /* If we timed out -> exit */
    12601231                        futex_up(&async_futex);
    1261                         return CAP_NIL;
     1232                        return 0;
    12621233                }
    12631234        }
     
    12671238        list_remove(&msg->link);
    12681239       
    1269         cap_handle_t chandle = msg->chandle;
     1240        ipc_callid_t callid = msg->callid;
    12701241        *call = msg->call;
    12711242        free(msg);
    12721243       
    12731244        futex_up(&async_futex);
    1274         return chandle;
     1245        return callid;
    12751246}
    12761247
     
    13351306 * Otherwise the call is routed to its connection fibril.
    13361307 *
    1337  * @param chandle  Handle of the incoming call.
    1338  * @param call     Data of the incoming call.
    1339  *
    1340  */
    1341 static void handle_call(cap_handle_t chandle, ipc_call_t *call)
     1308 * @param callid Hash of the incoming call.
     1309 * @param call   Data of the incoming call.
     1310 *
     1311 */
     1312static void handle_call(ipc_callid_t callid, ipc_call_t *call)
    13421313{
    13431314        assert(call);
    13441315       
    13451316        /* Kernel notification */
    1346         if ((chandle == CAP_NIL) && (call->flags & IPC_CALL_NOTIF)) {
     1317        if ((callid & IPC_CALLID_NOTIFICATION)) {
    13471318                fibril_t *fibril = (fibril_t *) __tcb_get()->fibril_data;
    13481319                unsigned oldsw = fibril->switches;
    13491320               
    1350                 process_notification(call);
     1321                process_notification(callid, call);
    13511322               
    13521323                if (oldsw != fibril->switches) {
     
    13741345                sysarg_t in_phone_hash = IPC_GET_ARG5(*call);
    13751346               
    1376                 async_port_handler_t handler = fallback_port_handler;
     1347                async_notification_handler_t handler = fallback_port_handler;
    13771348                void *data = fallback_port_data;
    13781349               
     
    13841355                }
    13851356               
    1386                 async_new_connection(call->in_task_id, in_phone_hash, chandle,
     1357                async_new_connection(call->in_task_id, in_phone_hash, callid,
    13871358                    call, handler, data);
    13881359                return;
     
    13901361       
    13911362        /* Try to route the call through the connection hash table */
    1392         if (route_call(chandle, call))
     1363        if (route_call(callid, call))
    13931364                return;
    13941365       
    13951366        /* Unknown call from unknown phone - hang it up */
    1396         ipc_answer_0(chandle, EHANGUP);
     1367        ipc_answer_0(callid, EHANGUP);
    13971368}
    13981369
     
    14891460               
    14901461                ipc_call_t call;
    1491                 int rc = ipc_wait_cycle(&call, timeout, flags);
     1462                ipc_callid_t callid = ipc_wait_cycle(&call, timeout, flags);
    14921463               
    14931464                atomic_dec(&threads_in_ipc_wait);
    14941465               
    1495                 assert(rc == EOK);
    1496 
    1497                 if (call.cap_handle == CAP_NIL) {
    1498                         if ((call.flags &
    1499                             (IPC_CALL_NOTIF | IPC_CALL_ANSWERED)) == 0) {
    1500                                 /* Neither a notification nor an answer. */
    1501                                 handle_expired_timeouts();
    1502                                 continue;
    1503                         }
     1466                if (!callid) {
     1467                        handle_expired_timeouts();
     1468                        continue;
    15041469                }
    1505 
    1506                 if (call.flags & IPC_CALL_ANSWERED)
     1470               
     1471                if (callid & IPC_CALLID_ANSWERED)
    15071472                        continue;
    1508 
    1509                 handle_call(call.cap_handle, &call);
    1510         }
    1511 
     1473               
     1474                handle_call(callid, &call);
     1475        }
     1476       
    15121477        return 0;
    15131478}
     
    16401605 * @param arg3    Service-defined payload argument.
    16411606 * @param arg4    Service-defined payload argument.
    1642  * @param dataptr If non-NULL, storage where the reply data will be stored.
     1607 * @param dataptr If non-NULL, storage where the reply data will be
     1608 *                stored.
    16431609 *
    16441610 * @return Hash of the sent message or 0 on error.
     
    17091675 *
    17101676 */
    1711 void async_wait_for(aid_t amsgid, int *retval)
     1677void async_wait_for(aid_t amsgid, sysarg_t *retval)
    17121678{
    17131679        assert(amsgid);
     
    17551721 *
    17561722 */
    1757 int async_wait_timeout(aid_t amsgid, int *retval, suseconds_t timeout)
     1723int async_wait_timeout(aid_t amsgid, sysarg_t *retval, suseconds_t timeout)
    17581724{
    17591725        assert(amsgid);
     
    18561822void async_usleep(suseconds_t timeout)
    18571823{
    1858         awaiter_t awaiter;
    1859         awaiter_initialize(&awaiter);
    1860        
    1861         awaiter.fid = fibril_get_id();
    1862        
    1863         getuptime(&awaiter.to_event.expires);
    1864         tv_add_diff(&awaiter.to_event.expires, timeout);
     1824        amsg_t *msg = amsg_create();
     1825        if (!msg)
     1826                return;
     1827       
     1828        msg->wdata.fid = fibril_get_id();
     1829       
     1830        getuptime(&msg->wdata.to_event.expires);
     1831        tv_add_diff(&msg->wdata.to_event.expires, timeout);
    18651832       
    18661833        futex_down(&async_futex);
    18671834       
    1868         async_insert_timeout(&awaiter);
     1835        async_insert_timeout(&msg->wdata);
    18691836       
    18701837        /* Leave the async_futex locked when entering this function */
     
    18721839       
    18731840        /* Futex is up automatically after fibril_switch() */
    1874 }
    1875 
    1876 /** Delay execution for the specified number of seconds
    1877  *
    1878  * @param sec Number of seconds to sleep
    1879  */
    1880 void async_sleep(unsigned int sec)
    1881 {
    1882         /*
    1883          * Sleep in 1000 second steps to support
    1884          * full argument range
    1885          */
    1886 
    1887         while (sec > 0) {
    1888                 unsigned int period = (sec > 1000) ? 1000 : sec;
    1889 
    1890                 async_usleep(period * 1000000);
    1891                 sec -= period;
    1892         }
     1841       
     1842        amsg_destroy(msg);
    18931843}
    18941844
     
    19121862 * @param r5      If non-NULL, storage for the 5th reply argument.
    19131863 *
    1914  * @return Return code of the reply or an error code.
    1915  *
    1916  */
    1917 int async_req_fast(async_exch_t *exch, sysarg_t imethod, sysarg_t arg1,
     1864 * @return Return code of the reply or a negative error code.
     1865 *
     1866 */
     1867sysarg_t async_req_fast(async_exch_t *exch, sysarg_t imethod, sysarg_t arg1,
    19181868    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t *r1, sysarg_t *r2,
    19191869    sysarg_t *r3, sysarg_t *r4, sysarg_t *r5)
     
    19261876            &result);
    19271877       
    1928         int rc;
     1878        sysarg_t rc;
    19291879        async_wait_for(aid, &rc);
    19301880       
     
    19641914 * @param r5      If non-NULL, storage for the 5th reply argument.
    19651915 *
    1966  * @return Return code of the reply or an error code.
    1967  *
    1968  */
    1969 int async_req_slow(async_exch_t *exch, sysarg_t imethod, sysarg_t arg1,
     1916 * @return Return code of the reply or a negative error code.
     1917 *
     1918 */
     1919sysarg_t async_req_slow(async_exch_t *exch, sysarg_t imethod, sysarg_t arg1,
    19701920    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *r1,
    19711921    sysarg_t *r2, sysarg_t *r3, sysarg_t *r4, sysarg_t *r5)
     
    19781928            &result);
    19791929       
    1980         int rc;
     1930        sysarg_t rc;
    19811931        async_wait_for(aid, &rc);
    19821932       
     
    20421992}
    20431993
    2044 int async_answer_0(cap_handle_t chandle, int retval)
    2045 {
    2046         return ipc_answer_0(chandle, retval);
    2047 }
    2048 
    2049 int async_answer_1(cap_handle_t chandle, int retval, sysarg_t arg1)
    2050 {
    2051         return ipc_answer_1(chandle, retval, arg1);
    2052 }
    2053 
    2054 int async_answer_2(cap_handle_t chandle, int retval, sysarg_t arg1,
     1994sysarg_t async_answer_0(ipc_callid_t callid, sysarg_t retval)
     1995{
     1996        return ipc_answer_0(callid, retval);
     1997}
     1998
     1999sysarg_t async_answer_1(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1)
     2000{
     2001        return ipc_answer_1(callid, retval, arg1);
     2002}
     2003
     2004sysarg_t async_answer_2(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
    20552005    sysarg_t arg2)
    20562006{
    2057         return ipc_answer_2(chandle, retval, arg1, arg2);
    2058 }
    2059 
    2060 int async_answer_3(cap_handle_t chandle, int retval, sysarg_t arg1,
     2007        return ipc_answer_2(callid, retval, arg1, arg2);
     2008}
     2009
     2010sysarg_t async_answer_3(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
    20612011    sysarg_t arg2, sysarg_t arg3)
    20622012{
    2063         return ipc_answer_3(chandle, retval, arg1, arg2, arg3);
    2064 }
    2065 
    2066 int async_answer_4(cap_handle_t chandle, int retval, sysarg_t arg1,
     2013        return ipc_answer_3(callid, retval, arg1, arg2, arg3);
     2014}
     2015
     2016sysarg_t async_answer_4(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
    20672017    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
    20682018{
    2069         return ipc_answer_4(chandle, retval, arg1, arg2, arg3, arg4);
    2070 }
    2071 
    2072 int async_answer_5(cap_handle_t chandle, int retval, sysarg_t arg1,
     2019        return ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4);
     2020}
     2021
     2022sysarg_t async_answer_5(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
    20732023    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
    20742024{
    2075         return ipc_answer_5(chandle, retval, arg1, arg2, arg3, arg4, arg5);
    2076 }
    2077 
    2078 int async_forward_fast(cap_handle_t chandle, async_exch_t *exch,
     2025        return ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5);
     2026}
     2027
     2028int async_forward_fast(ipc_callid_t callid, async_exch_t *exch,
    20792029    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode)
    20802030{
     
    20822032                return ENOENT;
    20832033       
    2084         return ipc_forward_fast(chandle, exch->phone, imethod, arg1, arg2, mode);
    2085 }
    2086 
    2087 int async_forward_slow(cap_handle_t chandle, async_exch_t *exch,
     2034        return ipc_forward_fast(callid, exch->phone, imethod, arg1, arg2, mode);
     2035}
     2036
     2037int async_forward_slow(ipc_callid_t callid, async_exch_t *exch,
    20882038    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
    20892039    sysarg_t arg4, sysarg_t arg5, unsigned int mode)
     
    20922042                return ENOENT;
    20932043       
    2094         return ipc_forward_slow(chandle, exch->phone, imethod, arg1, arg2, arg3,
     2044        return ipc_forward_slow(callid, exch->phone, imethod, arg1, arg2, arg3,
    20952045            arg4, arg5, mode);
    20962046}
     
    21052055 * @param arg3            User defined argument.
    21062056 *
    2107  * @return Zero on success or an error code.
     2057 * @return Zero on success or a negative error code.
    21082058 *
    21092059 */
     
    21182068            &answer);
    21192069       
    2120         int rc;
     2070        sysarg_t rc;
    21212071        async_wait_for(req, &rc);
    21222072        if (rc != EOK)
     
    21272077
    21282078static int async_connect_me_to_internal(int phone, sysarg_t arg1, sysarg_t arg2,
    2129     sysarg_t arg3, sysarg_t arg4, int *out_phone)
     2079    sysarg_t arg3, sysarg_t arg4)
    21302080{
    21312081        ipc_call_t result;
    2132        
    2133         // XXX: Workaround for GCC's inability to infer association between
    2134         // rc == EOK and *out_phone being assigned.
    2135         *out_phone = -1;
    21362082       
    21372083        amsg_t *msg = amsg_create();
     
    21452091            msg, reply_received);
    21462092       
    2147         int rc;
     2093        sysarg_t rc;
    21482094        async_wait_for((aid_t) msg, &rc);
    21492095       
     
    21512097                return rc;
    21522098       
    2153         *out_phone = (int) IPC_GET_ARG5(result);
    2154         return EOK;
     2099        return (int) IPC_GET_ARG5(result);
    21552100}
    21562101
     
    21822127        }
    21832128       
    2184         int phone;
    2185         int rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
    2186             0, &phone);
    2187         if (rc != EOK) {
    2188                 errno = rc;
     2129        int phone = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
     2130            0);
     2131        if (phone < 0) {
     2132                errno = phone;
    21892133                free(sess);
    21902134                return NULL;
     
    22352179        }
    22362180       
    2237         int phone;
    2238         int rc = async_connect_me_to_internal(exch->phone, iface, arg2,
    2239             arg3, 0, &phone);
    2240         if (rc != EOK) {
    2241                 errno = rc;
     2181        int phone = async_connect_me_to_internal(exch->phone, iface, arg2,
     2182            arg3, 0);
     2183        if (phone < 0) {
     2184                errno = phone;
    22422185                free(sess);
    22432186                return NULL;
     
    23062249        }
    23072250       
    2308         int phone;
    2309         int rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
    2310             IPC_FLAG_BLOCKING, &phone);
    2311        
    2312         if (rc != EOK) {
    2313                 errno = rc;
     2251        int phone = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
     2252            IPC_FLAG_BLOCKING);
     2253       
     2254        if (phone < 0) {
     2255                errno = phone;
    23142256                free(sess);
    23152257                return NULL;
     
    23602302        }
    23612303       
    2362         int phone;
    2363         int rc = async_connect_me_to_internal(exch->phone, iface, arg2,
    2364             arg3, IPC_FLAG_BLOCKING, &phone);
    2365         if (rc != EOK) {
    2366                 errno = rc;
     2304        int phone = async_connect_me_to_internal(exch->phone, iface, arg2,
     2305            arg3, IPC_FLAG_BLOCKING);
     2306        if (phone < 0) {
     2307                errno = phone;
    23672308                free(sess);
    23682309                return NULL;
     
    23962337        }
    23972338       
    2398         cap_handle_t phone;
    2399         int rc = ipc_connect_kbox(id, &phone);
    2400         if (rc != EOK) {
    2401                 errno = rc;
     2339        int phone = ipc_connect_kbox(id);
     2340        if (phone < 0) {
     2341                errno = phone;
    24022342                free(sess);
    24032343                return NULL;
     
    24302370 * @param sess Session to hung up.
    24312371 *
    2432  * @return Zero on success or an error code.
     2372 * @return Zero on success or a negative error code.
    24332373 *
    24342374 */
     
    25162456                } else if (mgmt == EXCHANGE_PARALLEL) {
    25172457                        int phone;
    2518                         int rc;
    25192458                       
    25202459                retry:
     
    25222461                         * Make a one-time attempt to connect a new data phone.
    25232462                         */
    2524                         rc = async_connect_me_to_internal(sess->phone, sess->arg1,
    2525                             sess->arg2, sess->arg3, 0, &phone);
    2526                         if (rc == EOK) {
     2463                        phone = async_connect_me_to_internal(sess->phone, sess->arg1,
     2464                            sess->arg2, sess->arg3, 0);
     2465                        if (phone >= 0) {
    25272466                                exch = (async_exch_t *) malloc(sizeof(async_exch_t));
    25282467                                if (exch != NULL) {
     
    26102549 *              base address. Cannot be NULL.
    26112550 *
    2612  * @return Zero on success or an error code from errno.h.
     2551 * @return Zero on success or a negative error code from errno.h.
    26132552 *
    26142553 */
     
    26392578 * So far, this wrapper is to be used from within a connection fibril.
    26402579 *
    2641  * @param chandle  Storage for the handle of the IPC_M_SHARE_IN call.
    2642  * @param size     Destination address space area size.
     2580 * @param callid Storage for the hash of the IPC_M_SHARE_IN call.
     2581 * @param size   Destination address space area size.
    26432582 *
    26442583 * @return True on success, false on failure.
    26452584 *
    26462585 */
    2647 bool async_share_in_receive(cap_handle_t *chandle, size_t *size)
    2648 {
    2649         assert(chandle);
     2586bool async_share_in_receive(ipc_callid_t *callid, size_t *size)
     2587{
     2588        assert(callid);
    26502589        assert(size);
    26512590       
    26522591        ipc_call_t data;
    2653         *chandle = async_get_call(&data);
     2592        *callid = async_get_call(&data);
    26542593       
    26552594        if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_IN)
     
    26662605 * argument.
    26672606 *
    2668  * @param chandle  Handle of the IPC_M_DATA_READ call to answer.
    2669  * @param src      Source address space base.
    2670  * @param flags    Flags to be used for sharing. Bits can be only cleared.
     2607 * @param callid Hash of the IPC_M_DATA_READ call to answer.
     2608 * @param src    Source address space base.
     2609 * @param flags  Flags to be used for sharing. Bits can be only cleared.
    26712610 *
    26722611 * @return Zero on success or a value from @ref errno.h on failure.
    26732612 *
    26742613 */
    2675 int async_share_in_finalize(cap_handle_t chandle, void *src, unsigned int flags)
    2676 {
    2677         return ipc_answer_3(chandle, EOK, (sysarg_t) src, (sysarg_t) flags,
     2614int async_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags)
     2615{
     2616        return ipc_answer_3(callid, EOK, (sysarg_t) src, (sysarg_t) flags,
    26782617            (sysarg_t) __entry);
    26792618}
     
    26852624 * @param flags Flags to be used for sharing. Bits can be only cleared.
    26862625 *
    2687  * @return Zero on success or an error code from errno.h.
     2626 * @return Zero on success or a negative error code from errno.h.
    26882627 *
    26892628 */
     
    27052644 * So far, this wrapper is to be used from within a connection fibril.
    27062645 *
    2707  * @param chandle Storage for the hash of the IPC_M_SHARE_OUT call.
    2708  * @param size     Storage for the source address space area size.
    2709  * @param flags    Storage for the sharing flags.
     2646 * @param callid Storage for the hash of the IPC_M_SHARE_OUT call.
     2647 * @param size   Storage for the source address space area size.
     2648 * @param flags  Storage for the sharing flags.
    27102649 *
    27112650 * @return True on success, false on failure.
    27122651 *
    27132652 */
    2714 bool async_share_out_receive(cap_handle_t *chandle, size_t *size,
    2715     unsigned int *flags)
    2716 {
    2717         assert(chandle);
     2653bool async_share_out_receive(ipc_callid_t *callid, size_t *size, unsigned int *flags)
     2654{
     2655        assert(callid);
    27182656        assert(size);
    27192657        assert(flags);
    27202658       
    27212659        ipc_call_t data;
    2722         *chandle = async_get_call(&data);
     2660        *callid = async_get_call(&data);
    27232661       
    27242662        if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_OUT)
     
    27362674 * argument.
    27372675 *
    2738  * @param chandle  Handle of the IPC_M_DATA_WRITE call to answer.
    2739  * @param dst      Address of the storage for the destination address space area
    2740  *                 base address.
    2741  *
    2742  * @return  Zero on success or a value from @ref errno.h on failure.
    2743  *
    2744  */
    2745 int async_share_out_finalize(cap_handle_t chandle, void **dst)
    2746 {
    2747         return ipc_answer_2(chandle, EOK, (sysarg_t) __entry, (sysarg_t) dst);
     2676 * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
     2677 * @param dst    Address of the storage for the destination address space area
     2678 *               base address.
     2679 *
     2680 * @return Zero on success or a value from @ref errno.h on failure.
     2681 *
     2682 */
     2683int async_share_out_finalize(ipc_callid_t callid, void **dst)
     2684{
     2685        return ipc_answer_2(callid, EOK, (sysarg_t) __entry, (sysarg_t) dst);
    27482686}
    27492687
     
    27712709 * @param size Size of the destination buffer.
    27722710 *
    2773  * @return Zero on success or an error code from errno.h.
     2711 * @return Zero on success or a negative error code from errno.h.
    27742712 *
    27752713 */
     
    27912729 * So far, this wrapper is to be used from within a connection fibril.
    27922730 *
    2793  * @param chandle  Storage for the handle of the IPC_M_DATA_READ.
    2794  * @param size     Storage for the maximum size. Can be NULL.
     2731 * @param callid Storage for the hash of the IPC_M_DATA_READ.
     2732 * @param size   Storage for the maximum size. Can be NULL.
    27952733 *
    27962734 * @return True on success, false on failure.
    27972735 *
    27982736 */
    2799 bool async_data_read_receive(cap_handle_t *chandle, size_t *size)
     2737bool async_data_read_receive(ipc_callid_t *callid, size_t *size)
    28002738{
    28012739        ipc_call_t data;
    2802         return async_data_read_receive_call(chandle, &data, size);
     2740        return async_data_read_receive_call(callid, &data, size);
    28032741}
    28042742
     
    28112749 * So far, this wrapper is to be used from within a connection fibril.
    28122750 *
    2813  * @param chandle  Storage for the handle of the IPC_M_DATA_READ.
    2814  * @param size     Storage for the maximum size. Can be NULL.
     2751 * @param callid Storage for the hash of the IPC_M_DATA_READ.
     2752 * @param size   Storage for the maximum size. Can be NULL.
    28152753 *
    28162754 * @return True on success, false on failure.
    28172755 *
    28182756 */
    2819 bool async_data_read_receive_call(cap_handle_t *chandle, ipc_call_t *data,
     2757bool async_data_read_receive_call(ipc_callid_t *callid, ipc_call_t *data,
    28202758    size_t *size)
    28212759{
    2822         assert(chandle);
     2760        assert(callid);
    28232761        assert(data);
    28242762       
    2825         *chandle = async_get_call(data);
     2763        *callid = async_get_call(data);
    28262764       
    28272765        if (IPC_GET_IMETHOD(*data) != IPC_M_DATA_READ)
     
    28402778 * argument.
    28412779 *
    2842  * @param chandle  Handle of the IPC_M_DATA_READ call to answer.
    2843  * @param src      Source address for the IPC_M_DATA_READ call.
    2844  * @param size     Size for the IPC_M_DATA_READ call. Can be smaller than
    2845  *                 the maximum size announced by the sender.
    2846  *
    2847  * @return  Zero on success or a value from @ref errno.h on failure.
    2848  *
    2849  */
    2850 int async_data_read_finalize(cap_handle_t chandle, const void *src, size_t size)
    2851 {
    2852         return ipc_answer_2(chandle, EOK, (sysarg_t) src, (sysarg_t) size);
     2780 * @param callid Hash of the IPC_M_DATA_READ call to answer.
     2781 * @param src    Source address for the IPC_M_DATA_READ call.
     2782 * @param size   Size for the IPC_M_DATA_READ call. Can be smaller than
     2783 *               the maximum size announced by the sender.
     2784 *
     2785 * @return Zero on success or a value from @ref errno.h on failure.
     2786 *
     2787 */
     2788int async_data_read_finalize(ipc_callid_t callid, const void *src, size_t size)
     2789{
     2790        return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) size);
    28532791}
    28542792
     
    28632801                return ENOENT;
    28642802       
    2865         cap_handle_t chandle;
    2866         if (!async_data_read_receive(&chandle, NULL)) {
    2867                 ipc_answer_0(chandle, EINVAL);
     2803        ipc_callid_t callid;
     2804        if (!async_data_read_receive(&callid, NULL)) {
     2805                ipc_answer_0(callid, EINVAL);
    28682806                return EINVAL;
    28692807        }
     
    28722810            dataptr);
    28732811        if (msg == 0) {
    2874                 ipc_answer_0(chandle, EINVAL);
     2812                ipc_answer_0(callid, EINVAL);
    28752813                return EINVAL;
    28762814        }
    28772815       
    2878         int retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0,
     2816        int retval = ipc_forward_fast(callid, exch->phone, 0, 0, 0,
    28792817            IPC_FF_ROUTE_FROM_ME);
    28802818        if (retval != EOK) {
    28812819                async_forget(msg);
    2882                 ipc_answer_0(chandle, retval);
     2820                ipc_answer_0(callid, retval);
    28832821                return retval;
    28842822        }
    28852823       
    2886         int rc;
     2824        sysarg_t rc;
    28872825        async_wait_for(msg, &rc);
    28882826       
     
    28962834 * @param size Size of the source buffer.
    28972835 *
    2898  * @return Zero on success or an error code from errno.h.
     2836 * @return Zero on success or a negative error code from errno.h.
    28992837 *
    29002838 */
     
    29162854 * So far, this wrapper is to be used from within a connection fibril.
    29172855 *
    2918  * @param chandle  Storage for the handle of the IPC_M_DATA_WRITE.
    2919  * @param size     Storage for the suggested size. May be NULL.
    2920  *
    2921  * @return  True on success, false on failure.
    2922  *
    2923  */
    2924 bool async_data_write_receive(cap_handle_t *chandle, size_t *size)
     2856 * @param callid Storage for the hash of the IPC_M_DATA_WRITE.
     2857 * @param size   Storage for the suggested size. May be NULL.
     2858 *
     2859 * @return True on success, false on failure.
     2860 *
     2861 */
     2862bool async_data_write_receive(ipc_callid_t *callid, size_t *size)
    29252863{
    29262864        ipc_call_t data;
    2927         return async_data_write_receive_call(chandle, &data, size);
     2865        return async_data_write_receive_call(callid, &data, size);
    29282866}
    29292867
     
    29362874 * So far, this wrapper is to be used from within a connection fibril.
    29372875 *
    2938  * @param chandle  Storage for the handle of the IPC_M_DATA_WRITE.
    2939  * @param data     Storage for the ipc call data.
    2940  * @param size     Storage for the suggested size. May be NULL.
     2876 * @param callid Storage for the hash of the IPC_M_DATA_WRITE.
     2877 * @param data   Storage for the ipc call data.
     2878 * @param size   Storage for the suggested size. May be NULL.
    29412879 *
    29422880 * @return True on success, false on failure.
    29432881 *
    29442882 */
    2945 bool async_data_write_receive_call(cap_handle_t *chandle, ipc_call_t *data,
     2883bool async_data_write_receive_call(ipc_callid_t *callid, ipc_call_t *data,
    29462884    size_t *size)
    29472885{
    2948         assert(chandle);
     2886        assert(callid);
    29492887        assert(data);
    29502888       
    2951         *chandle = async_get_call(data);
     2889        *callid = async_get_call(data);
    29522890       
    29532891        if (IPC_GET_IMETHOD(*data) != IPC_M_DATA_WRITE)
     
    29662904 * argument.
    29672905 *
    2968  * @param chandle  Handle of the IPC_M_DATA_WRITE call to answer.
    2969  * @param dst      Final destination address for the IPC_M_DATA_WRITE call.
    2970  * @param size     Final size for the IPC_M_DATA_WRITE call.
    2971  *
    2972  * @return  Zero on success or a value from @ref errno.h on failure.
    2973  *
    2974  */
    2975 int async_data_write_finalize(cap_handle_t chandle, void *dst, size_t size)
    2976 {
    2977         return ipc_answer_2(chandle, EOK, (sysarg_t) dst, (sysarg_t) size);
     2906 * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
     2907 * @param dst    Final destination address for the IPC_M_DATA_WRITE call.
     2908 * @param size   Final size for the IPC_M_DATA_WRITE call.
     2909 *
     2910 * @return Zero on success or a value from @ref errno.h on failure.
     2911 *
     2912 */
     2913int async_data_write_finalize(ipc_callid_t callid, void *dst, size_t size)
     2914{
     2915        return ipc_answer_2(callid, EOK, (sysarg_t) dst, (sysarg_t) size);
    29782916}
    29792917
     
    30052943        assert(data);
    30062944       
    3007         cap_handle_t chandle;
     2945        ipc_callid_t callid;
    30082946        size_t size;
    3009         if (!async_data_write_receive(&chandle, &size)) {
    3010                 ipc_answer_0(chandle, EINVAL);
     2947        if (!async_data_write_receive(&callid, &size)) {
     2948                ipc_answer_0(callid, EINVAL);
    30112949                return EINVAL;
    30122950        }
    30132951       
    30142952        if (size < min_size) {
    3015                 ipc_answer_0(chandle, EINVAL);
     2953                ipc_answer_0(callid, EINVAL);
    30162954                return EINVAL;
    30172955        }
    30182956       
    30192957        if ((max_size > 0) && (size > max_size)) {
    3020                 ipc_answer_0(chandle, EINVAL);
     2958                ipc_answer_0(callid, EINVAL);
    30212959                return EINVAL;
    30222960        }
    30232961       
    30242962        if ((granularity > 0) && ((size % granularity) != 0)) {
    3025                 ipc_answer_0(chandle, EINVAL);
     2963                ipc_answer_0(callid, EINVAL);
    30262964                return EINVAL;
    30272965        }
     
    30352973       
    30362974        if (arg_data == NULL) {
    3037                 ipc_answer_0(chandle, ENOMEM);
     2975                ipc_answer_0(callid, ENOMEM);
    30382976                return ENOMEM;
    30392977        }
    30402978       
    3041         int rc = async_data_write_finalize(chandle, arg_data, size);
     2979        int rc = async_data_write_finalize(callid, arg_data, size);
    30422980        if (rc != EOK) {
    30432981                free(arg_data);
     
    30623000 *
    30633001 */
    3064 void async_data_write_void(int retval)
    3065 {
    3066         cap_handle_t chandle;
    3067         async_data_write_receive(&chandle, NULL);
    3068         ipc_answer_0(chandle, retval);
     3002void async_data_write_void(sysarg_t retval)
     3003{
     3004        ipc_callid_t callid;
     3005        async_data_write_receive(&callid, NULL);
     3006        ipc_answer_0(callid, retval);
    30693007}
    30703008
     
    30793017                return ENOENT;
    30803018       
    3081         cap_handle_t chandle;
    3082         if (!async_data_write_receive(&chandle, NULL)) {
    3083                 ipc_answer_0(chandle, EINVAL);
     3019        ipc_callid_t callid;
     3020        if (!async_data_write_receive(&callid, NULL)) {
     3021                ipc_answer_0(callid, EINVAL);
    30843022                return EINVAL;
    30853023        }
     
    30883026            dataptr);
    30893027        if (msg == 0) {
    3090                 ipc_answer_0(chandle, EINVAL);
     3028                ipc_answer_0(callid, EINVAL);
    30913029                return EINVAL;
    30923030        }
    30933031       
    3094         int retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0,
     3032        int retval = ipc_forward_fast(callid, exch->phone, 0, 0, 0,
    30953033            IPC_FF_ROUTE_FROM_ME);
    30963034        if (retval != EOK) {
    30973035                async_forget(msg);
    3098                 ipc_answer_0(chandle, retval);
     3036                ipc_answer_0(callid, retval);
    30993037                return retval;
    31003038        }
    31013039       
    3102         int rc;
     3040        sysarg_t rc;
    31033041        async_wait_for(msg, &rc);
    31043042       
     
    31213059        /* Accept the phone */
    31223060        ipc_call_t call;
    3123         cap_handle_t chandle = async_get_call(&call);
    3124         cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(call);
    3125        
    3126         if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) || (phandle < 0)) {
    3127                 async_answer_0(chandle, EINVAL);
     3061        ipc_callid_t callid = async_get_call(&call);
     3062        int phone = (int) IPC_GET_ARG5(call);
     3063       
     3064        if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) ||
     3065            (phone < 0)) {
     3066                async_answer_0(callid, EINVAL);
    31283067                return NULL;
    31293068        }
     
    31313070        async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
    31323071        if (sess == NULL) {
    3133                 async_answer_0(chandle, ENOMEM);
     3072                async_answer_0(callid, ENOMEM);
    31343073                return NULL;
    31353074        }
     
    31373076        sess->iface = 0;
    31383077        sess->mgmt = mgmt;
    3139         sess->phone = phandle;
     3078        sess->phone = phone;
    31403079        sess->arg1 = 0;
    31413080        sess->arg2 = 0;
     
    31503089       
    31513090        /* Acknowledge the connected phone */
    3152         async_answer_0(chandle, EOK);
     3091        async_answer_0(callid, EOK);
    31533092       
    31543093        return sess;
     
    31713110async_sess_t *async_callback_receive_start(exch_mgmt_t mgmt, ipc_call_t *call)
    31723111{
    3173         cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*call);
    3174        
    3175         if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) || (phandle < 0))
     3112        int phone = (int) IPC_GET_ARG5(*call);
     3113       
     3114        if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) ||
     3115            (phone < 0))
    31763116                return NULL;
    31773117       
     
    31823122        sess->iface = 0;
    31833123        sess->mgmt = mgmt;
    3184         sess->phone = phandle;
     3124        sess->phone = phone;
    31853125        sess->arg1 = 0;
    31863126        sess->arg2 = 0;
     
    32043144}
    32053145
    3206 bool async_state_change_receive(cap_handle_t *chandle, sysarg_t *arg1,
     3146bool async_state_change_receive(ipc_callid_t *callid, sysarg_t *arg1,
    32073147    sysarg_t *arg2, sysarg_t *arg3)
    32083148{
    3209         assert(chandle);
     3149        assert(callid);
    32103150       
    32113151        ipc_call_t call;
    3212         *chandle = async_get_call(&call);
     3152        *callid = async_get_call(&call);
    32133153       
    32143154        if (IPC_GET_IMETHOD(call) != IPC_M_STATE_CHANGE_AUTHORIZE)
     
    32253165}
    32263166
    3227 int async_state_change_finalize(cap_handle_t chandle, async_exch_t *other_exch)
    3228 {
    3229         return ipc_answer_1(chandle, EOK, other_exch->phone);
     3167int async_state_change_finalize(ipc_callid_t callid, async_exch_t *other_exch)
     3168{
     3169        return ipc_answer_1(callid, EOK, other_exch->phone);
    32303170}
    32313171
Note: See TracChangeset for help on using the changeset viewer.