Ignore:
File:
1 edited

Legend:

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

    rc7bbf029 re35bf88  
    4343 * framework will automatically take care of most synchronization problems.
    4444 *
     45 * Default semantics:
     46 * - async_send_*(): Send asynchronously. If the kernel refuses to send
     47 *                   more messages, [ try to get responses from kernel, if
     48 *                   nothing found, might try synchronous ]
     49 *
    4550 * Example of use (pseudo C):
    4651 *
     
    5358 *   int fibril1(void *arg)
    5459 *   {
    55  *     conn = async_connect_me_to();
     60 *     conn = ipc_connect_me_to();
    5661 *     c1 = async_send(conn);
    5762 *     c2 = async_send(conn);
     
    7277 *   {
    7378 *     if (want_refuse) {
    74  *       async_answer_0(icallid, ELIMIT);
     79 *       ipc_answer_0(icallid, ELIMIT);
    7580 *       return;
    7681 *     }
    77  *     async_answer_0(icallid, EOK);
     82 *     ipc_answer_0(icallid, EOK);
    7883 *
    7984 *     callid = async_get_call(&call);
    8085 *     somehow_handle_the_call(callid, call);
    81  *     async_answer_2(callid, 1, 2, 3);
     86 *     ipc_answer_2(callid, 1, 2, 3);
    8287 *
    8388 *     callid = async_get_call(&call);
     
    8792 */
    8893
    89 #define LIBC_ASYNC_C_
    90 #include <ipc/ipc.h>
     94#include <futex.h>
    9195#include <async.h>
    92 #undef LIBC_ASYNC_C_
    93 
    94 #include <futex.h>
     96#include <async_priv.h>
    9597#include <fibril.h>
    9698#include <stdio.h>
    9799#include <adt/hash_table.h>
    98100#include <adt/list.h>
     101#include <ipc/ipc.h>
    99102#include <assert.h>
    100103#include <errno.h>
     
    102105#include <arch/barrier.h>
    103106#include <bool.h>
    104 #include <stdlib.h>
    105 #include <malloc.h>
    106 #include "private/async.h"
    107107
    108108atomic_t async_futex = FUTEX_INITIALIZER;
     
    120120        ipc_call_t *dataptr;
    121121       
    122         sysarg_t retval;
     122        ipcarg_t retval;
    123123} amsg_t;
    124124
    125125/**
    126  * Structures of this type are used to group information about
    127  * a call and about a message queue link.
     126 * Structures of this type are used to group information about a call and a
     127 * message queue link.
    128128 */
    129129typedef struct {
     
    134134
    135135typedef struct {
    136         sysarg_t in_task_hash;
    137         link_t link;
    138         int refcnt;
    139         void *data;
    140 } client_t;
    141 
    142 typedef struct {
    143136        awaiter_t wdata;
    144137       
     
    146139        link_t link;
    147140       
    148         /** Incoming client task hash. */
    149         sysarg_t in_task_hash;
    150141        /** Incoming phone hash. */
    151         sysarg_t in_phone_hash;
    152        
    153         /** Link to the client tracking structure. */
    154         client_t *client;
     142        ipcarg_t in_phone_hash;
    155143       
    156144        /** Messages that should be delivered to this fibril. */
     
    170158
    171159/** Identifier of the incoming connection handled by the current fibril. */
    172 static fibril_local connection_t *FIBRIL_connection;
    173 
    174 static void *default_client_data_constructor(void)
    175 {
    176         return NULL;
    177 }
    178 
    179 static void default_client_data_destructor(void *data)
    180 {
    181 }
    182 
    183 static async_client_data_ctor_t async_client_data_create =
    184     default_client_data_constructor;
    185 static async_client_data_dtor_t async_client_data_destroy =
    186     default_client_data_destructor;
    187 
    188 void async_set_client_data_constructor(async_client_data_ctor_t ctor)
    189 {
    190         async_client_data_create = ctor;
    191 }
    192 
    193 void async_set_client_data_destructor(async_client_data_dtor_t dtor)
    194 {
    195         async_client_data_destroy = dtor;
    196 }
    197 
    198 void *async_client_data_get(void)
    199 {
    200         assert(FIBRIL_connection);
    201         return FIBRIL_connection->client->data;
    202 }
    203 
    204 /** Default fibril function that gets called to handle new connection.
    205  *
    206  * This function is defined as a weak symbol - to be redefined in user code.
    207  *
    208  * @param callid Hash of the incoming call.
    209  * @param call   Data of the incoming call.
    210  *
    211  */
    212 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)
    213 {
    214         ipc_answer_0(callid, ENOENT);
    215 }
     160fibril_local connection_t *FIBRIL_connection;
     161
     162static void default_client_connection(ipc_callid_t callid, ipc_call_t *call);
     163static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call);
    216164
    217165/**
     
    219167 */
    220168static async_client_conn_t client_connection = default_client_connection;
    221 
    222 /** Default fibril function that gets called to handle interrupt notifications.
    223  *
    224  * This function is defined as a weak symbol - to be redefined in user code.
    225  *
    226  * @param callid Hash of the incoming call.
    227  * @param call   Data of the incoming call.
    228  *
    229  */
    230 static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call)
    231 {
    232 }
    233169
    234170/**
     
    238174static async_client_conn_t interrupt_received = default_interrupt_received;
    239175
    240 static hash_table_t client_hash_table;
    241176static hash_table_t conn_hash_table;
    242177static LIST_INITIALIZE(timeout_list);
    243178
    244 #define CLIENT_HASH_TABLE_BUCKETS  32
    245 #define CONN_HASH_TABLE_BUCKETS    32
    246 
    247 static hash_index_t client_hash(unsigned long key[])
     179#define CONN_HASH_TABLE_CHAINS  32
     180
     181/** Compute hash into the connection hash table based on the source phone hash.
     182 *
     183 * @param key Pointer to source phone hash.
     184 *
     185 * @return Index into the connection hash table.
     186 *
     187 */
     188static hash_index_t conn_hash(unsigned long *key)
    248189{
    249190        assert(key);
    250         return (((key[0]) >> 4) % CLIENT_HASH_TABLE_BUCKETS);
    251 }
    252 
    253 static int client_compare(unsigned long key[], hash_count_t keys, link_t *item)
    254 {
    255         client_t *client = hash_table_get_instance(item, client_t, link);
    256         return (key[0] == client->in_task_hash);
    257 }
    258 
    259 static void client_remove(link_t *item)
    260 {
    261 }
    262 
    263 /** Operations for the client hash table. */
    264 static hash_table_operations_t client_hash_table_ops = {
    265         .hash = client_hash,
    266         .compare = client_compare,
    267         .remove_callback = client_remove
    268 };
    269 
    270 /** Compute hash into the connection hash table based on the source phone hash.
    271  *
    272  * @param key Pointer to source phone hash.
    273  *
    274  * @return Index into the connection hash table.
    275  *
    276  */
    277 static hash_index_t conn_hash(unsigned long key[])
    278 {
    279         assert(key);
    280         return (((key[0]) >> 4) % CONN_HASH_TABLE_BUCKETS);
     191        return (((*key) >> 4) % CONN_HASH_TABLE_CHAINS);
    281192}
    282193
     
    292203static int conn_compare(unsigned long key[], hash_count_t keys, link_t *item)
    293204{
    294         connection_t *conn = hash_table_get_instance(item, connection_t, link);
    295         return (key[0] == conn->in_phone_hash);
    296 }
    297 
     205        connection_t *hs = hash_table_get_instance(item, connection_t, link);
     206        return (key[0] == hs->in_phone_hash);
     207}
     208
     209/** Connection hash table removal callback function.
     210 *
     211 * This function is called whenever a connection is removed from the connection
     212 * hash table.
     213 *
     214 * @param item Connection hash table item being removed.
     215 *
     216 */
    298217static void conn_remove(link_t *item)
    299218{
    300 }
     219        free(hash_table_get_instance(item, connection_t, link));
     220}
     221
    301222
    302223/** Operations for the connection hash table. */
     
    319240        link_t *tmp = timeout_list.next;
    320241        while (tmp != &timeout_list) {
    321                 awaiter_t *cur
    322                     = list_get_instance(tmp, awaiter_t, to_event.link);
     242                awaiter_t *cur;
    323243               
     244                cur = list_get_instance(tmp, awaiter_t, to_event.link);
    324245                if (tv_gteq(&cur->to_event.expires, &wd->to_event.expires))
    325246                        break;
    326                
    327247                tmp = tmp->next;
    328248        }
     
    341261 *
    342262 * @return False if the call doesn't match any connection.
    343  * @return True if the call was passed to the respective connection fibril.
     263 *         True if the call was passed to the respective connection fibril.
    344264 *
    345265 */
     
    368288        list_append(&msg->link, &conn->msg_queue);
    369289       
    370         if (IPC_GET_IMETHOD(*call) == IPC_M_PHONE_HUNGUP)
     290        if (IPC_GET_METHOD(*call) == IPC_M_PHONE_HUNGUP)
    371291                conn->close_callid = callid;
    372292       
     
    432352       
    433353        fid_t fid = fibril_create(notification_fibril, msg);
    434         if (fid == 0) {
    435                 free(msg);
    436                 futex_up(&async_futex);
    437                 return false;
    438         }
    439        
    440354        fibril_add_ready(fid);
    441355       
     
    484398                         * the first IPC_M_PHONE_HUNGUP call and continues to
    485399                         * call async_get_call_timeout(). Repeat
    486                          * IPC_M_PHONE_HUNGUP until the caller notices.
     400                         * IPC_M_PHONE_HUNGUP until the caller notices. 
    487401                         */
    488402                        memset(call, 0, sizeof(ipc_call_t));
    489                         IPC_SET_IMETHOD(*call, IPC_M_PHONE_HUNGUP);
     403                        IPC_SET_METHOD(*call, IPC_M_PHONE_HUNGUP);
    490404                        futex_up(&async_futex);
    491405                        return conn->close_callid;
    492406                }
    493                
     407
    494408                if (usecs)
    495409                        async_insert_timeout(&conn->wdata);
     
    529443}
    530444
     445/** Default fibril function that gets called to handle new connection.
     446 *
     447 * This function is defined as a weak symbol - to be redefined in user code.
     448 *
     449 * @param callid Hash of the incoming call.
     450 * @param call   Data of the incoming call.
     451 *
     452 */
     453static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)
     454{
     455        ipc_answer_0(callid, ENOENT);
     456}
     457
     458/** Default fibril function that gets called to handle interrupt notifications.
     459 *
     460 * This function is defined as a weak symbol - to be redefined in user code.
     461 *
     462 * @param callid Hash of the incoming call.
     463 * @param call   Data of the incoming call.
     464 *
     465 */
     466static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call)
     467{
     468}
     469
    531470/** Wrapper for client connection fibril.
    532471 *
     
    542481{
    543482        /*
    544          * Setup fibril-local connection pointer.
     483         * Setup fibril-local connection pointer and call client_connection().
     484         *
    545485         */
    546486        FIBRIL_connection = (connection_t *) arg;
    547        
    548         futex_down(&async_futex);
    549        
    550         /*
    551          * Add our reference for the current connection in the client task
    552          * tracking structure. If this is the first reference, create and
    553          * hash in a new tracking structure.
    554          */
    555        
    556         unsigned long key = FIBRIL_connection->in_task_hash;
    557         link_t *lnk = hash_table_find(&client_hash_table, &key);
    558        
    559         client_t *client;
    560        
    561         if (lnk) {
    562                 client = hash_table_get_instance(lnk, client_t, link);
    563                 client->refcnt++;
    564         } else {
    565                 client = malloc(sizeof(client_t));
    566                 if (!client) {
    567                         ipc_answer_0(FIBRIL_connection->callid, ENOMEM);
    568                         futex_up(&async_futex);
    569                         return 0;
    570                 }
    571                
    572                 client->in_task_hash = FIBRIL_connection->in_task_hash;
    573                
    574                 async_serialize_start();
    575                 client->data = async_client_data_create();
    576                 async_serialize_end();
    577                
    578                 client->refcnt = 1;
    579                 hash_table_insert(&client_hash_table, &key, &client->link);
    580         }
    581        
    582         futex_up(&async_futex);
    583        
    584         FIBRIL_connection->client = client;
    585        
    586         /*
    587          * Call the connection handler function.
    588          */
    589487        FIBRIL_connection->cfibril(FIBRIL_connection->callid,
    590488            &FIBRIL_connection->call);
    591489       
    592         /*
    593          * Remove the reference for this client task connection.
    594          */
    595         bool destroy;
    596        
     490        /* Remove myself from the connection hash table */
    597491        futex_down(&async_futex);
    598        
    599         if (--client->refcnt == 0) {
    600                 hash_table_remove(&client_hash_table, &key, 1);
    601                 destroy = true;
    602         } else
    603                 destroy = false;
    604        
    605         futex_up(&async_futex);
    606        
    607         if (destroy) {
    608                 if (client->data)
    609                         async_client_data_destroy(client->data);
    610                
    611                 free(client);
    612         }
    613        
    614         /*
    615          * Remove myself from the connection hash table.
    616          */
    617         futex_down(&async_futex);
    618         key = FIBRIL_connection->in_phone_hash;
     492        unsigned long key = FIBRIL_connection->in_phone_hash;
    619493        hash_table_remove(&conn_hash_table, &key, 1);
    620494        futex_up(&async_futex);
    621495       
    622         /*
    623          * Answer all remaining messages with EHANGUP.
    624          */
     496        /* Answer all remaining messages with EHANGUP */
    625497        while (!list_empty(&FIBRIL_connection->msg_queue)) {
    626                 msg_t *msg =
    627                     list_get_instance(FIBRIL_connection->msg_queue.next, msg_t,
    628                     link);
     498                msg_t *msg;
    629499               
     500                msg = list_get_instance(FIBRIL_connection->msg_queue.next,
     501                    msg_t, link);
    630502                list_remove(&msg->link);
    631503                ipc_answer_0(msg->callid, EHANGUP);
     
    633505        }
    634506       
    635         /*
    636          * If the connection was hung-up, answer the last call,
    637          * i.e. IPC_M_PHONE_HUNGUP.
    638          */
    639507        if (FIBRIL_connection->close_callid)
    640508                ipc_answer_0(FIBRIL_connection->close_callid, EOK);
    641509       
    642         free(FIBRIL_connection);
    643510        return 0;
    644511}
     
    650517 * particular fibrils.
    651518 *
    652  * @param in_task_hash  Identification of the incoming connection.
    653519 * @param in_phone_hash Identification of the incoming connection.
    654520 * @param callid        Hash of the opening IPC_M_CONNECT_ME_TO call.
     
    663529 *
    664530 */
    665 fid_t async_new_connection(sysarg_t in_task_hash, sysarg_t in_phone_hash,
    666     ipc_callid_t callid, ipc_call_t *call,
    667     void (*cfibril)(ipc_callid_t, ipc_call_t *))
     531fid_t async_new_connection(ipcarg_t in_phone_hash, ipc_callid_t callid,
     532    ipc_call_t *call, void (*cfibril)(ipc_callid_t, ipc_call_t *))
    668533{
    669534        connection_t *conn = malloc(sizeof(*conn));
     
    671536                if (callid)
    672537                        ipc_answer_0(callid, ENOMEM);
    673                
    674                 return (uintptr_t) NULL;
    675         }
    676        
    677         conn->in_task_hash = in_task_hash;
     538                return NULL;
     539        }
     540       
    678541        conn->in_phone_hash = in_phone_hash;
    679542        list_initialize(&conn->msg_queue);
     
    689552        conn->wdata.fid = fibril_create(connection_fibril, conn);
    690553       
    691         if (conn->wdata.fid == 0) {
     554        if (!conn->wdata.fid) {
    692555                free(conn);
    693                
    694556                if (callid)
    695557                        ipc_answer_0(callid, ENOMEM);
    696                
    697                 return (uintptr_t) NULL;
     558                return NULL;
    698559        }
    699560       
     
    721582static void handle_call(ipc_callid_t callid, ipc_call_t *call)
    722583{
    723         /* Unrouted call - take some default action */
     584        /* Unrouted call - do some default behaviour */
    724585        if ((callid & IPC_CALLID_NOTIFICATION)) {
    725586                process_notification(callid, call);
    726                 return;
    727         }
    728        
    729         switch (IPC_GET_IMETHOD(*call)) {
     587                goto out;
     588        }
     589       
     590        switch (IPC_GET_METHOD(*call)) {
    730591        case IPC_M_CONNECT_ME:
    731592        case IPC_M_CONNECT_ME_TO:
    732                 /* Open new connection with fibril, etc. */
    733                 async_new_connection(call->in_task_hash, IPC_GET_ARG5(*call),
    734                     callid, call, client_connection);
    735                 return;
     593                /* Open new connection with fibril etc. */
     594                async_new_connection(IPC_GET_ARG5(*call), callid, call,
     595                    client_connection);
     596                goto out;
    736597        }
    737598       
    738599        /* Try to route the call through the connection hash table */
    739600        if (route_call(callid, call))
    740                 return;
     601                goto out;
    741602       
    742603        /* Unknown call from unknown phone - hang it up */
    743604        ipc_answer_0(callid, EHANGUP);
     605        return;
     606       
     607out:
     608        ;
    744609}
    745610
     
    754619        link_t *cur = timeout_list.next;
    755620        while (cur != &timeout_list) {
    756                 awaiter_t *waiter =
    757                     list_get_instance(cur, awaiter_t, to_event.link);
     621                awaiter_t *waiter;
    758622               
     623                waiter = list_get_instance(cur, awaiter_t, to_event.link);
    759624                if (tv_gt(&waiter->to_event.expires, &tv))
    760625                        break;
    761                
     626
    762627                cur = cur->next;
    763                
     628
    764629                list_remove(&waiter->to_event.link);
    765630                waiter->to_event.inlist = false;
     
    788653        while (true) {
    789654                if (fibril_switch(FIBRIL_FROM_MANAGER)) {
    790                         futex_up(&async_futex);
     655                        futex_up(&async_futex); 
    791656                        /*
    792657                         * async_futex is always held when entering a manager
     
    811676                                continue;
    812677                        } else
    813                                 timeout = tv_sub(&waiter->to_event.expires, &tv);
     678                                timeout = tv_sub(&waiter->to_event.expires,
     679                                    &tv);
    814680                } else
    815681                        timeout = SYNCH_NO_TIMEOUT;
    816682               
    817683                futex_up(&async_futex);
    818                
     684
    819685                atomic_inc(&threads_in_ipc_wait);
    820686               
     
    824690               
    825691                atomic_dec(&threads_in_ipc_wait);
    826                
     692
    827693                if (!callid) {
    828694                        handle_expired_timeouts();
     
    863729{
    864730        fid_t fid = fibril_create(async_manager_fibril, NULL);
    865         if (fid != 0)
    866                 fibril_add_manager(fid);
     731        fibril_add_manager(fid);
    867732}
    868733
     
    875740/** Initialize the async framework.
    876741 *
    877  */
    878 void __async_init(void)
    879 {
    880         if (!hash_table_create(&client_hash_table, CLIENT_HASH_TABLE_BUCKETS, 1,
    881             &client_hash_table_ops))
    882                 abort();
    883        
    884         if (!hash_table_create(&conn_hash_table, CONN_HASH_TABLE_BUCKETS, 1,
    885             &conn_hash_table_ops))
    886                 abort();
     742 * @return Zero on success or an error code.
     743 */
     744int __async_init(void)
     745{
     746        if (!hash_table_create(&conn_hash_table, CONN_HASH_TABLE_CHAINS, 1,
     747            &conn_hash_table_ops)) {
     748                printf("%s: Cannot create async hash table\n", "libc");
     749                return ENOMEM;
     750        }
     751       
     752        return 0;
    887753}
    888754
     
    897763 * @param retval Value returned in the answer.
    898764 * @param data   Call data of the answer.
    899  *
    900765 */
    901766static void reply_received(void *arg, int retval, ipc_call_t *data)
     
    942807 *
    943808 */
    944 aid_t async_send_fast(int phoneid, sysarg_t method, sysarg_t arg1,
    945     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr)
    946 {
    947         amsg_t *msg = malloc(sizeof(amsg_t));
     809aid_t async_send_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
     810    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)
     811{
     812        amsg_t *msg = malloc(sizeof(*msg));
    948813       
    949814        if (!msg)
     
    954819       
    955820        msg->wdata.to_event.inlist = false;
    956        
    957         /*
    958          * We may sleep in the next method,
    959          * but it will use its own means
    960          */
     821        /* We may sleep in the next method, but it will use its own mechanism */
    961822        msg->wdata.active = true;
    962823       
     
    985846 *
    986847 */
    987 aid_t async_send_slow(int phoneid, sysarg_t method, sysarg_t arg1,
    988     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
     848aid_t async_send_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
     849    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5,
    989850    ipc_call_t *dataptr)
    990851{
    991         amsg_t *msg = malloc(sizeof(amsg_t));
     852        amsg_t *msg = malloc(sizeof(*msg));
    992853       
    993854        if (!msg)
     
    998859       
    999860        msg->wdata.to_event.inlist = false;
    1000        
    1001         /*
    1002          * We may sleep in the next method,
    1003          * but it will use its own means
    1004          */
     861        /* We may sleep in next method, but it will use its own mechanism */
    1005862        msg->wdata.active = true;
    1006863       
     
    1018875 *
    1019876 */
    1020 void async_wait_for(aid_t amsgid, sysarg_t *retval)
     877void async_wait_for(aid_t amsgid, ipcarg_t *retval)
    1021878{
    1022879        amsg_t *msg = (amsg_t *) amsgid;
     
    1054911 *
    1055912 */
    1056 int async_wait_timeout(aid_t amsgid, sysarg_t *retval, suseconds_t timeout)
     913int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout)
    1057914{
    1058915        amsg_t *msg = (amsg_t *) amsgid;
     
    1101958void async_usleep(suseconds_t timeout)
    1102959{
    1103         amsg_t *msg = malloc(sizeof(amsg_t));
     960        amsg_t *msg = malloc(sizeof(*msg));
    1104961       
    1105962        if (!msg)
     
    11661023 *
    11671024 */
    1168 sysarg_t async_req_fast(int phoneid, sysarg_t method, sysarg_t arg1,
    1169     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t *r1, sysarg_t *r2,
    1170     sysarg_t *r3, sysarg_t *r4, sysarg_t *r5)
     1025ipcarg_t async_req_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
     1026    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t *r1, ipcarg_t *r2,
     1027    ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5)
    11711028{
    11721029        ipc_call_t result;
     
    11741031            &result);
    11751032       
    1176         sysarg_t rc;
     1033        ipcarg_t rc;
    11771034        async_wait_for(eid, &rc);
    11781035       
     
    12151072 *
    12161073 */
    1217 sysarg_t async_req_slow(int phoneid, sysarg_t method, sysarg_t arg1,
    1218     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *r1,
    1219     sysarg_t *r2, sysarg_t *r3, sysarg_t *r4, sysarg_t *r5)
     1074ipcarg_t async_req_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
     1075    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *r1,
     1076    ipcarg_t *r2, ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5)
    12201077{
    12211078        ipc_call_t result;
     
    12231080            &result);
    12241081       
    1225         sysarg_t rc;
     1082        ipcarg_t rc;
    12261083        async_wait_for(eid, &rc);
    12271084       
     
    12441101}
    12451102
    1246 void async_msg_0(int phone, sysarg_t imethod)
    1247 {
    1248         ipc_call_async_0(phone, imethod, NULL, NULL, true);
    1249 }
    1250 
    1251 void async_msg_1(int phone, sysarg_t imethod, sysarg_t arg1)
    1252 {
    1253         ipc_call_async_1(phone, imethod, arg1, NULL, NULL, true);
    1254 }
    1255 
    1256 void async_msg_2(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2)
    1257 {
    1258         ipc_call_async_2(phone, imethod, arg1, arg2, NULL, NULL, true);
    1259 }
    1260 
    1261 void async_msg_3(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
    1262     sysarg_t arg3)
    1263 {
    1264         ipc_call_async_3(phone, imethod, arg1, arg2, arg3, NULL, NULL, true);
    1265 }
    1266 
    1267 void async_msg_4(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
    1268     sysarg_t arg3, sysarg_t arg4)
    1269 {
    1270         ipc_call_async_4(phone, imethod, arg1, arg2, arg3, arg4, NULL, NULL,
    1271             true);
    1272 }
    1273 
    1274 void async_msg_5(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
    1275     sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
    1276 {
    1277         ipc_call_async_5(phone, imethod, arg1, arg2, arg3, arg4, arg5, NULL,
    1278             NULL, true);
    1279 }
    1280 
    1281 sysarg_t async_answer_0(ipc_callid_t callid, sysarg_t retval)
    1282 {
    1283         return ipc_answer_0(callid, retval);
    1284 }
    1285 
    1286 sysarg_t async_answer_1(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1)
    1287 {
    1288         return ipc_answer_1(callid, retval, arg1);
    1289 }
    1290 
    1291 sysarg_t async_answer_2(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
    1292     sysarg_t arg2)
    1293 {
    1294         return ipc_answer_2(callid, retval, arg1, arg2);
    1295 }
    1296 
    1297 sysarg_t async_answer_3(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
    1298     sysarg_t arg2, sysarg_t arg3)
    1299 {
    1300         return ipc_answer_3(callid, retval, arg1, arg2, arg3);
    1301 }
    1302 
    1303 sysarg_t async_answer_4(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
    1304     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
    1305 {
    1306         return ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4);
    1307 }
    1308 
    1309 sysarg_t async_answer_5(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
    1310     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
    1311 {
    1312         return ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5);
    1313 }
    1314 
    1315 int async_forward_fast(ipc_callid_t callid, int phoneid, sysarg_t imethod,
    1316     sysarg_t arg1, sysarg_t arg2, unsigned int mode)
    1317 {
    1318         return ipc_forward_fast(callid, phoneid, imethod, arg1, arg2, mode);
    1319 }
    1320 
    1321 int async_forward_slow(ipc_callid_t callid, int phoneid, sysarg_t imethod,
    1322     sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
    1323     unsigned int mode)
    1324 {
    1325         return ipc_forward_slow(callid, phoneid, imethod, arg1, arg2, arg3, arg4,
    1326             arg5, mode);
    1327 }
    1328 
    1329 /** Wrapper for making IPC_M_CONNECT_TO_ME calls using the async framework.
    1330  *
     1103/** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
     1104 *
    13311105 * Ask through phone for a new connection to some service.
    13321106 *
    1333  * @param phone           Phone handle used for contacting the other side.
    1334  * @param arg1            User defined argument.
    1335  * @param arg2            User defined argument.
    1336  * @param arg3            User defined argument.
    1337  * @param client_receiver Connection handing routine.
    1338  *
    1339  * @return New phone handle on success or a negative error code.
    1340  *
    1341  */
    1342 int async_connect_to_me(int phone, sysarg_t arg1, sysarg_t arg2,
    1343     sysarg_t arg3, async_client_conn_t client_receiver)
    1344 {
    1345         sysarg_t task_hash;
    1346         sysarg_t phone_hash;
    1347         int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3,
    1348             NULL, NULL, NULL, &task_hash, &phone_hash);
    1349         if (rc != EOK)
     1107 * @param phoneid       Phone handle used for contacting the other side.
     1108 * @param arg1          User defined argument.
     1109 * @param arg2          User defined argument.
     1110 * @param arg3          User defined argument.
     1111 *
     1112 * @return              New phone handle on success or a negative error code.
     1113 */
     1114int
     1115async_connect_me_to(int phoneid, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3)
     1116{
     1117        int rc;
     1118        ipcarg_t newphid;
     1119
     1120        rc = async_req_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, NULL,
     1121            NULL, NULL, NULL, &newphid);
     1122       
     1123        if (rc != EOK) 
    13501124                return rc;
    1351        
    1352         if (client_receiver != NULL)
    1353                 async_new_connection(task_hash, phone_hash, 0, NULL,
    1354                     client_receiver);
    1355        
    1356         return EOK;
     1125
     1126        return newphid;
    13571127}
    13581128
    13591129/** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
    1360  *
    1361  * Ask through phone for a new connection to some service.
    1362  *
    1363  * @param phone Phone handle used for contacting the other side.
    1364  * @param arg1  User defined argument.
    1365  * @param arg2  User defined argument.
    1366  * @param arg3  User defined argument.
    1367  *
    1368  * @return New phone handle on success or a negative error code.
    1369  *
    1370  */
    1371 int async_connect_me_to(int phone, sysarg_t arg1, sysarg_t arg2,
    1372     sysarg_t arg3)
    1373 {
    1374         sysarg_t newphid;
    1375         int rc = async_req_3_5(phone, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
    1376             NULL, NULL, NULL, NULL, &newphid);
    1377        
    1378         if (rc != EOK)
    1379                 return rc;
    1380        
    1381         return newphid;
    1382 }
    1383 
    1384 /** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
    1385  *
     1130 *
    13861131 * Ask through phone for a new connection to some service and block until
    13871132 * success.
    13881133 *
    1389  * @param phoneid Phone handle used for contacting the other side.
    1390  * @param arg1    User defined argument.
    1391  * @param arg2    User defined argument.
    1392  * @param arg3    User defined argument.
    1393  *
    1394  * @return New phone handle on success or a negative error code.
    1395  *
    1396  */
    1397 int async_connect_me_to_blocking(int phoneid, sysarg_t arg1, sysarg_t arg2,
    1398     sysarg_t arg3)
    1399 {
    1400         sysarg_t newphid;
    1401         int rc = async_req_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
     1134 * @param phoneid       Phone handle used for contacting the other side.
     1135 * @param arg1          User defined argument.
     1136 * @param arg2          User defined argument.
     1137 * @param arg3          User defined argument.
     1138 *
     1139 * @return              New phone handle on success or a negative error code.
     1140 */
     1141int
     1142async_connect_me_to_blocking(int phoneid, ipcarg_t arg1, ipcarg_t arg2,
     1143    ipcarg_t arg3)
     1144{
     1145        int rc;
     1146        ipcarg_t newphid;
     1147
     1148        rc = async_req_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
    14021149            IPC_FLAG_BLOCKING, NULL, NULL, NULL, NULL, &newphid);
    14031150       
    1404         if (rc != EOK)
     1151        if (rc != EOK) 
    14051152                return rc;
    1406        
     1153
    14071154        return newphid;
    14081155}
    14091156
    1410 /** Connect to a task specified by id.
    1411  *
    1412  */
    1413 int async_connect_kbox(task_id_t id)
    1414 {
    1415         return ipc_connect_kbox(id);
    1416 }
    1417 
    1418 /** Wrapper for ipc_hangup.
    1419  *
    1420  * @param phone Phone handle to hung up.
    1421  *
    1422  * @return Zero on success or a negative error code.
    1423  *
    1424  */
    1425 int async_hangup(int phone)
    1426 {
    1427         return ipc_hangup(phone);
    1428 }
    1429 
    1430 /** Interrupt one thread of this task from waiting for IPC. */
    1431 void async_poke(void)
    1432 {
    1433         ipc_poke();
    1434 }
    1435 
    1436 /** Wrapper for IPC_M_SHARE_IN calls using the async framework.
    1437  *
    1438  * @param phoneid Phone that will be used to contact the receiving side.
    1439  * @param dst     Destination address space area base.
    1440  * @param size    Size of the destination address space area.
    1441  * @param arg     User defined argument.
    1442  * @param flags   Storage for the received flags. Can be NULL.
    1443  *
    1444  * @return Zero on success or a negative error code from errno.h.
    1445  *
    1446  */
    1447 int async_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg,
    1448     unsigned int *flags)
    1449 {
     1157/** Wrapper for making IPC_M_SHARE_IN calls using the async framework.
     1158 *
     1159 * @param phoneid       Phone that will be used to contact the receiving side.
     1160 * @param dst           Destination address space area base.
     1161 * @param size          Size of the destination address space area.
     1162 * @param arg           User defined argument.
     1163 * @param flags         Storage where the received flags will be stored. Can be
     1164 *                      NULL.
     1165 *
     1166 * @return              Zero on success or a negative error code from errno.h.
     1167 */
     1168int async_share_in_start(int phoneid, void *dst, size_t size, ipcarg_t arg,
     1169    int *flags)
     1170{
     1171        int res;
    14501172        sysarg_t tmp_flags;
    1451         int res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst,
    1452             (sysarg_t) size, arg, NULL, &tmp_flags);
    1453        
     1173        res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (ipcarg_t) dst,
     1174            (ipcarg_t) size, arg, NULL, &tmp_flags);
    14541175        if (flags)
    1455                 *flags = (unsigned int) tmp_flags;
    1456        
     1176                *flags = tmp_flags;
    14571177        return res;
    14581178}
     
    14601180/** Wrapper for receiving the IPC_M_SHARE_IN calls using the async framework.
    14611181 *
    1462  * This wrapper only makes it more comfortable to receive IPC_M_SHARE_IN
    1463  * calls so that the user doesn't have to remember the meaning of each IPC
    1464  * argument.
     1182 * This wrapper only makes it more comfortable to receive IPC_M_SHARE_IN calls
     1183 * so that the user doesn't have to remember the meaning of each IPC argument.
    14651184 *
    14661185 * So far, this wrapper is to be used from within a connection fibril.
    14671186 *
    1468  * @param callid Storage for the hash of the IPC_M_SHARE_IN call.
    1469  * @param size   Destination address space area size.
    1470  *
    1471  * @return True on success, false on failure.
    1472  *
    1473  */
    1474 bool async_share_in_receive(ipc_callid_t *callid, size_t *size)
    1475 {
     1187 * @param callid        Storage where the hash of the IPC_M_SHARE_IN call will
     1188 *                      be stored.
     1189 * @param size          Destination address space area size.   
     1190 *
     1191 * @return              Non-zero on success, zero on failure.
     1192 */
     1193int async_share_in_receive(ipc_callid_t *callid, size_t *size)
     1194{
     1195        ipc_call_t data;
     1196       
    14761197        assert(callid);
    14771198        assert(size);
    1478        
     1199
     1200        *callid = async_get_call(&data);
     1201        if (IPC_GET_METHOD(data) != IPC_M_SHARE_IN)
     1202                return 0;
     1203        *size = (size_t) IPC_GET_ARG2(data);
     1204        return 1;
     1205}
     1206
     1207/** Wrapper for answering the IPC_M_SHARE_IN calls using the async framework.
     1208 *
     1209 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls
     1210 * so that the user doesn't have to remember the meaning of each IPC argument.
     1211 *
     1212 * @param callid        Hash of the IPC_M_DATA_READ call to answer.
     1213 * @param src           Source address space base.
     1214 * @param flags         Flags to be used for sharing. Bits can be only cleared.
     1215 *
     1216 * @return              Zero on success or a value from @ref errno.h on failure.
     1217 */
     1218int async_share_in_finalize(ipc_callid_t callid, void *src, int flags)
     1219{
     1220        return ipc_share_in_finalize(callid, src, flags);
     1221}
     1222
     1223/** Wrapper for making IPC_M_SHARE_OUT calls using the async framework.
     1224 *
     1225 * @param phoneid       Phone that will be used to contact the receiving side.
     1226 * @param src           Source address space area base address.
     1227 * @param flags         Flags to be used for sharing. Bits can be only cleared.
     1228 *
     1229 * @return              Zero on success or a negative error code from errno.h.
     1230 */
     1231int async_share_out_start(int phoneid, void *src, int flags)
     1232{
     1233        return async_req_3_0(phoneid, IPC_M_SHARE_OUT, (ipcarg_t) src, 0,
     1234            (ipcarg_t) flags);
     1235}
     1236
     1237/** Wrapper for receiving the IPC_M_SHARE_OUT calls using the async framework.
     1238 *
     1239 * This wrapper only makes it more comfortable to receive IPC_M_SHARE_OUT calls
     1240 * so that the user doesn't have to remember the meaning of each IPC argument.
     1241 *
     1242 * So far, this wrapper is to be used from within a connection fibril.
     1243 *
     1244 * @param callid        Storage where the hash of the IPC_M_SHARE_OUT call will
     1245 *                      be stored.
     1246 * @param size          Storage where the source address space area size will be
     1247 *                      stored.
     1248 * @param flags         Storage where the sharing flags will be stored.
     1249 *
     1250 * @return              Non-zero on success, zero on failure.
     1251 */
     1252int async_share_out_receive(ipc_callid_t *callid, size_t *size, int *flags)
     1253{
    14791254        ipc_call_t data;
    1480         *callid = async_get_call(&data);
    1481        
    1482         if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_IN)
    1483                 return false;
    1484        
    1485         *size = (size_t) IPC_GET_ARG2(data);
    1486         return true;
    1487 }
    1488 
    1489 /** Wrapper for answering the IPC_M_SHARE_IN calls using the async framework.
    1490  *
    1491  * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
    1492  * calls so that the user doesn't have to remember the meaning of each IPC
    1493  * argument.
    1494  *
    1495  * @param callid Hash of the IPC_M_DATA_READ call to answer.
    1496  * @param src    Source address space base.
    1497  * @param flags  Flags to be used for sharing. Bits can be only cleared.
    1498  *
    1499  * @return Zero on success or a value from @ref errno.h on failure.
    1500  *
    1501  */
    1502 int async_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags)
    1503 {
    1504         return ipc_share_in_finalize(callid, src, flags);
    1505 }
    1506 
    1507 /** Wrapper for IPC_M_SHARE_OUT calls using the async framework.
    1508  *
    1509  * @param phoneid Phone that will be used to contact the receiving side.
    1510  * @param src     Source address space area base address.
    1511  * @param flags   Flags to be used for sharing. Bits can be only cleared.
    1512  *
    1513  * @return Zero on success or a negative error code from errno.h.
    1514  *
    1515  */
    1516 int async_share_out_start(int phoneid, void *src, unsigned int flags)
    1517 {
    1518         return async_req_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0,
    1519             (sysarg_t) flags);
    1520 }
    1521 
    1522 /** Wrapper for receiving the IPC_M_SHARE_OUT calls using the async framework.
    1523  *
    1524  * This wrapper only makes it more comfortable to receive IPC_M_SHARE_OUT
    1525  * calls so that the user doesn't have to remember the meaning of each IPC
    1526  * argument.
    1527  *
    1528  * So far, this wrapper is to be used from within a connection fibril.
    1529  *
    1530  * @param callid Storage for the hash of the IPC_M_SHARE_OUT call.
    1531  * @param size   Storage for the source address space area size.
    1532  * @param flags  Storage for the sharing flags.
    1533  *
    1534  * @return True on success, false on failure.
    1535  *
    1536  */
    1537 bool async_share_out_receive(ipc_callid_t *callid, size_t *size, unsigned int *flags)
    1538 {
     1255       
    15391256        assert(callid);
    15401257        assert(size);
    15411258        assert(flags);
    1542        
     1259
     1260        *callid = async_get_call(&data);
     1261        if (IPC_GET_METHOD(data) != IPC_M_SHARE_OUT)
     1262                return 0;
     1263        *size = (size_t) IPC_GET_ARG2(data);
     1264        *flags = (int) IPC_GET_ARG3(data);
     1265        return 1;
     1266}
     1267
     1268/** Wrapper for answering the IPC_M_SHARE_OUT calls using the async framework.
     1269 *
     1270 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT calls
     1271 * so that the user doesn't have to remember the meaning of each IPC argument.
     1272 *
     1273 * @param callid        Hash of the IPC_M_DATA_WRITE call to answer.
     1274 * @param dst           Destination address space area base address.   
     1275 *
     1276 * @return              Zero on success or a value from @ref errno.h on failure.
     1277 */
     1278int async_share_out_finalize(ipc_callid_t callid, void *dst)
     1279{
     1280        return ipc_share_out_finalize(callid, dst);
     1281}
     1282
     1283
     1284/** Wrapper for making IPC_M_DATA_READ calls using the async framework.
     1285 *
     1286 * @param phoneid       Phone that will be used to contact the receiving side.
     1287 * @param dst           Address of the beginning of the destination buffer.
     1288 * @param size          Size of the destination buffer.
     1289 *
     1290 * @return              Zero on success or a negative error code from errno.h.
     1291 */
     1292int async_data_read_start(int phoneid, void *dst, size_t size)
     1293{
     1294        return async_req_2_0(phoneid, IPC_M_DATA_READ, (ipcarg_t) dst,
     1295            (ipcarg_t) size);
     1296}
     1297
     1298/** Wrapper for receiving the IPC_M_DATA_READ calls using the async framework.
     1299 *
     1300 * This wrapper only makes it more comfortable to receive IPC_M_DATA_READ calls
     1301 * so that the user doesn't have to remember the meaning of each IPC argument.
     1302 *
     1303 * So far, this wrapper is to be used from within a connection fibril.
     1304 *
     1305 * @param callid        Storage where the hash of the IPC_M_DATA_READ call will
     1306 *                      be stored.
     1307 * @param size          Storage where the maximum size will be stored. Can be
     1308 *                      NULL.
     1309 *
     1310 * @return              Non-zero on success, zero on failure.
     1311 */
     1312int async_data_read_receive(ipc_callid_t *callid, size_t *size)
     1313{
    15431314        ipc_call_t data;
     1315       
     1316        assert(callid);
     1317
    15441318        *callid = async_get_call(&data);
    1545        
    1546         if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_OUT)
    1547                 return false;
    1548        
    1549         *size = (size_t) IPC_GET_ARG2(data);
    1550         *flags = (unsigned int) IPC_GET_ARG3(data);
    1551         return true;
    1552 }
    1553 
    1554 /** Wrapper for answering the IPC_M_SHARE_OUT calls using the async framework.
    1555  *
    1556  * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT
    1557  * calls so that the user doesn't have to remember the meaning of each IPC
    1558  * argument.
    1559  *
    1560  * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
    1561  * @param dst    Destination address space area base address.
    1562  *
    1563  * @return Zero on success or a value from @ref errno.h on failure.
    1564  *
    1565  */
    1566 int async_share_out_finalize(ipc_callid_t callid, void *dst)
    1567 {
    1568         return ipc_share_out_finalize(callid, dst);
    1569 }
    1570 
    1571 /** Wrapper for IPC_M_DATA_READ calls using the async framework.
    1572  *
    1573  * @param phoneid Phone that will be used to contact the receiving side.
    1574  * @param dst     Address of the beginning of the destination buffer.
    1575  * @param size    Size of the destination buffer.
    1576  * @param flags   Flags to control the data transfer.
    1577  *
    1578  * @return Zero on success or a negative error code from errno.h.
    1579  *
    1580  */
    1581 int
    1582 async_data_read_start_generic(int phoneid, void *dst, size_t size, int flags)
    1583 {
    1584         return async_req_3_0(phoneid, IPC_M_DATA_READ, (sysarg_t) dst,
    1585             (sysarg_t) size, (sysarg_t) flags);
    1586 }
    1587 
    1588 /** Wrapper for receiving the IPC_M_DATA_READ calls using the async framework.
    1589  *
    1590  * This wrapper only makes it more comfortable to receive IPC_M_DATA_READ
    1591  * calls so that the user doesn't have to remember the meaning of each IPC
    1592  * argument.
    1593  *
    1594  * So far, this wrapper is to be used from within a connection fibril.
    1595  *
    1596  * @param callid Storage for the hash of the IPC_M_DATA_READ.
    1597  * @param size   Storage for the maximum size. Can be NULL.
    1598  *
    1599  * @return True on success, false on failure.
    1600  *
    1601  */
    1602 bool async_data_read_receive(ipc_callid_t *callid, size_t *size)
    1603 {
    1604         assert(callid);
    1605        
    1606         ipc_call_t data;
    1607         *callid = async_get_call(&data);
    1608        
    1609         if (IPC_GET_IMETHOD(data) != IPC_M_DATA_READ)
    1610                 return false;
    1611        
     1319        if (IPC_GET_METHOD(data) != IPC_M_DATA_READ)
     1320                return 0;
    16121321        if (size)
    16131322                *size = (size_t) IPC_GET_ARG2(data);
    1614        
    1615         return true;
     1323        return 1;
    16161324}
    16171325
    16181326/** Wrapper for answering the IPC_M_DATA_READ calls using the async framework.
    16191327 *
    1620  * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
    1621  * calls so that the user doesn't have to remember the meaning of each IPC
    1622  * argument.
    1623  *
    1624  * @param callid Hash of the IPC_M_DATA_READ call to answer.
    1625  * @param src    Source address for the IPC_M_DATA_READ call.
    1626  * @param size   Size for the IPC_M_DATA_READ call. Can be smaller than
    1627  *               the maximum size announced by the sender.
    1628  *
    1629  * @return Zero on success or a value from @ref errno.h on failure.
    1630  *
     1328 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls
     1329 * so that the user doesn't have to remember the meaning of each IPC argument.
     1330 *
     1331 * @param callid        Hash of the IPC_M_DATA_READ call to answer.
     1332 * @param src           Source address for the IPC_M_DATA_READ call.
     1333 * @param size          Size for the IPC_M_DATA_READ call. Can be smaller than
     1334 *                      the maximum size announced by the sender.
     1335 *
     1336 * @return              Zero on success or a value from @ref errno.h on failure.
    16311337 */
    16321338int async_data_read_finalize(ipc_callid_t callid, const void *src, size_t size)
     
    16371343/** Wrapper for forwarding any read request
    16381344 *
    1639  */
    1640 int async_data_read_forward_fast(int phoneid, sysarg_t method, sysarg_t arg1,
    1641     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr)
     1345 *
     1346 */
     1347int async_data_read_forward_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
     1348    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)
    16421349{
    16431350        ipc_callid_t callid;
     
    16621369        }
    16631370       
    1664         sysarg_t rc;
     1371        ipcarg_t rc;
    16651372        async_wait_for(msg, &rc);
    16661373       
     
    16681375}
    16691376
    1670 /** Wrapper for IPC_M_DATA_WRITE calls using the async framework.
     1377/** Wrapper for making IPC_M_DATA_WRITE calls using the async framework.
    16711378 *
    16721379 * @param phoneid Phone that will be used to contact the receiving side.
    16731380 * @param src     Address of the beginning of the source buffer.
    16741381 * @param size    Size of the source buffer.
    1675  * @param flags   Flags to control the data transfer.
    16761382 *
    16771383 * @return Zero on success or a negative error code from errno.h.
    16781384 *
    16791385 */
    1680 int
    1681 async_data_write_start_generic(int phoneid, const void *src, size_t size,
    1682     int flags)
    1683 {
    1684         return async_req_3_0(phoneid, IPC_M_DATA_WRITE, (sysarg_t) src,
    1685             (sysarg_t) size, (sysarg_t) flags);
     1386int async_data_write_start(int phoneid, const void *src, size_t size)
     1387{
     1388        return async_req_2_0(phoneid, IPC_M_DATA_WRITE, (ipcarg_t) src,
     1389            (ipcarg_t) size);
    16861390}
    16871391
    16881392/** Wrapper for receiving the IPC_M_DATA_WRITE calls using the async framework.
    16891393 *
    1690  * This wrapper only makes it more comfortable to receive IPC_M_DATA_WRITE
    1691  * calls so that the user doesn't have to remember the meaning of each IPC
    1692  * argument.
     1394 * This wrapper only makes it more comfortable to receive IPC_M_DATA_WRITE calls
     1395 * so that the user doesn't have to remember the meaning of each IPC argument.
    16931396 *
    16941397 * So far, this wrapper is to be used from within a connection fibril.
    16951398 *
    1696  * @param callid Storage for the hash of the IPC_M_DATA_WRITE.
    1697  * @param size   Storage for the suggested size. May be NULL.
    1698  *
    1699  * @return True on success, false on failure.
    1700  *
    1701  */
    1702 bool async_data_write_receive(ipc_callid_t *callid, size_t *size)
    1703 {
     1399 * @param callid Storage where the hash of the IPC_M_DATA_WRITE call will
     1400 *               be stored.
     1401 * @param size   Storage where the suggested size will be stored. May be
     1402 *               NULL
     1403 *
     1404 * @return Non-zero on success, zero on failure.
     1405 *
     1406 */
     1407int async_data_write_receive(ipc_callid_t *callid, size_t *size)
     1408{
     1409        ipc_call_t data;
     1410       
    17041411        assert(callid);
    17051412       
    1706         ipc_call_t data;
    17071413        *callid = async_get_call(&data);
    1708        
    1709         if (IPC_GET_IMETHOD(data) != IPC_M_DATA_WRITE)
    1710                 return false;
     1414        if (IPC_GET_METHOD(data) != IPC_M_DATA_WRITE)
     1415                return 0;
    17111416       
    17121417        if (size)
    17131418                *size = (size_t) IPC_GET_ARG2(data);
    17141419       
    1715         return true;
     1420        return 1;
    17161421}
    17171422
    17181423/** Wrapper for answering the IPC_M_DATA_WRITE calls using the async framework.
    17191424 *
    1720  * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE
    1721  * calls so that the user doesn't have to remember the meaning of each IPC
    1722  * argument.
     1425 * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE calls
     1426 * so that the user doesn't have to remember the meaning of each IPC argument.
    17231427 *
    17241428 * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
     
    18161520 *
    18171521 */
    1818 void async_data_write_void(sysarg_t retval)
     1522void async_data_write_void(const int retval)
    18191523{
    18201524        ipc_callid_t callid;
     
    18251529/** Wrapper for forwarding any data that is about to be received
    18261530 *
    1827  */
    1828 int async_data_write_forward_fast(int phoneid, sysarg_t method, sysarg_t arg1,
    1829     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr)
     1531 *
     1532 */
     1533int async_data_write_forward_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
     1534    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)
    18301535{
    18311536        ipc_callid_t callid;
     
    18501555        }
    18511556       
    1852         sysarg_t rc;
     1557        ipcarg_t rc;
    18531558        async_wait_for(msg, &rc);
    18541559       
Note: See TracChangeset for help on using the changeset viewer.