Changeset 64d2b10 in mainline for uspace/lib/c/generic


Ignore:
Timestamp:
2011-01-29T11:35:03Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ffa2c8ef
Parents:
2c577e0b
Message:

libc: do not intermix low-level IPC methods with async framework methods

Location:
uspace/lib/c/generic
Files:
15 edited

Legend:

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

    r2c577e0b r64d2b10  
    7777 *   {
    7878 *     if (want_refuse) {
    79  *       ipc_answer_0(icallid, ELIMIT);
     79 *       async_answer_0(icallid, ELIMIT);
    8080 *       return;
    8181 *     }
    82  *     ipc_answer_0(icallid, EOK);
     82 *     async_answer_0(icallid, EOK);
    8383 *
    8484 *     callid = async_get_call(&call);
    8585 *     somehow_handle_the_call(callid, call);
    86  *     ipc_answer_2(callid, 1, 2, 3);
     86 *     async_answer_2(callid, 1, 2, 3);
    8787 *
    8888 *     callid = async_get_call(&call);
     
    9292 */
    9393
     94#define LIBC_ASYNC_C_
     95#include <ipc/ipc.h>
     96#include <async.h>
     97#undef LIBC_ASYNC_C_
     98
    9499#include <futex.h>
    95 #include <async.h>
    96100#include <fibril.h>
    97101#include <stdio.h>
    98102#include <adt/hash_table.h>
    99103#include <adt/list.h>
    100 #include <ipc/ipc.h>
    101104#include <assert.h>
    102105#include <errno.h>
     
    12351238}
    12361239
     1240void async_msg_0(int phone, sysarg_t imethod)
     1241{
     1242        ipc_call_async_0(phone, imethod, NULL, NULL, true);
     1243}
     1244
     1245void async_msg_1(int phone, sysarg_t imethod, sysarg_t arg1)
     1246{
     1247        ipc_call_async_1(phone, imethod, arg1, NULL, NULL, true);
     1248}
     1249
     1250void async_msg_2(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2)
     1251{
     1252        ipc_call_async_2(phone, imethod, arg1, arg2, NULL, NULL, true);
     1253}
     1254
     1255void async_msg_3(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
     1256    sysarg_t arg3)
     1257{
     1258        ipc_call_async_3(phone, imethod, arg1, arg2, arg3, NULL, NULL, true);
     1259}
     1260
     1261void async_msg_4(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
     1262    sysarg_t arg3, sysarg_t arg4)
     1263{
     1264        ipc_call_async_4(phone, imethod, arg1, arg2, arg3, arg4, NULL, NULL,
     1265            true);
     1266}
     1267
     1268void async_msg_5(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
     1269    sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
     1270{
     1271        ipc_call_async_5(phone, imethod, arg1, arg2, arg3, arg4, arg5, NULL,
     1272            NULL, true);
     1273}
     1274
     1275sysarg_t async_answer_0(ipc_callid_t callid, sysarg_t retval)
     1276{
     1277        return ipc_answer_0(callid, retval);
     1278}
     1279
     1280sysarg_t async_answer_1(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1)
     1281{
     1282        return ipc_answer_1(callid, retval, arg1);
     1283}
     1284
     1285sysarg_t async_answer_2(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
     1286    sysarg_t arg2)
     1287{
     1288        return ipc_answer_2(callid, retval, arg1, arg2);
     1289}
     1290
     1291sysarg_t async_answer_3(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
     1292    sysarg_t arg2, sysarg_t arg3)
     1293{
     1294        return ipc_answer_3(callid, retval, arg1, arg2, arg3);
     1295}
     1296
     1297sysarg_t async_answer_4(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
     1298    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
     1299{
     1300        return ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4);
     1301}
     1302
     1303sysarg_t async_answer_5(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
     1304    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
     1305{
     1306        return ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5);
     1307}
     1308
     1309int async_forward_fast(ipc_callid_t callid, int phoneid, int imethod,
     1310    sysarg_t arg1, sysarg_t arg2, int mode)
     1311{
     1312        return ipc_forward_fast(callid, phoneid, imethod, arg1, arg2, mode);
     1313}
     1314
     1315int async_forward_slow(ipc_callid_t callid, int phoneid, int imethod,
     1316    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
     1317    int mode)
     1318{
     1319        return ipc_forward_slow(callid, phoneid, imethod, arg1, arg2, arg3, arg4,
     1320            arg5, mode);
     1321}
     1322
    12371323/** Wrapper for making IPC_M_CONNECT_TO_ME calls using the async framework.
    12381324 *
     
    13141400       
    13151401        return newphid;
     1402}
     1403
     1404/** Connect to a task specified by id.
     1405 *
     1406 */
     1407int async_connect_kbox(task_id_t id)
     1408{
     1409        return ipc_connect_kbox(id);
     1410}
     1411
     1412/** Wrapper for ipc_hangup.
     1413 *
     1414 * @param phone Phone handle to hung up.
     1415 *
     1416 * @return Zero on success or a negative error code.
     1417 *
     1418 */
     1419int async_hangup(int phone)
     1420{
     1421        return ipc_hangup(phone);
     1422}
     1423
     1424/** Interrupt one thread of this task from waiting for IPC. */
     1425void async_poke(void)
     1426{
     1427        ipc_poke();
    13161428}
    13171429
     
    15031615
    15041616/** Wrapper for forwarding any read request
    1505  *
    15061617 *
    15071618 */
     
    16901801/** Wrapper for forwarding any data that is about to be received
    16911802 *
    1692  *
    16931803 */
    16941804int async_data_write_forward_fast(int phoneid, sysarg_t method, sysarg_t arg1,
  • uspace/lib/c/generic/async_sess.c

    r2c577e0b r64d2b10  
    9999
    100100#include <async_sess.h>
    101 #include <ipc/ipc.h>
    102101#include <fibril_synch.h>
    103102#include <adt/list.h>
     
    200199                list_remove(&conn->global_link);
    201200               
    202                 ipc_hangup(conn->data_phone);
     201                async_hangup(conn->data_phone);
    203202                free(conn);
    204203        }
     
    260259                        data_phone = conn->data_phone;
    261260                        free(conn);
    262                         ipc_hangup(data_phone);
     261                        async_hangup(data_phone);
    263262                        goto retry;
    264263                } else {
     
    292291                 * means that we simply hang up.
    293292                 */
    294                 ipc_hangup(data_phone);
     293                async_hangup(data_phone);
    295294                fibril_mutex_unlock(&async_sess_mutex);
    296295                return;
  • uspace/lib/c/generic/ddi.c

    r2c577e0b r64d2b10  
    127127}
    128128
     129/** Register IRQ notification.
     130 *
     131 * @param inr    IRQ number.
     132 * @param devno  Device number of the device generating inr.
     133 * @param method Use this method for notifying me.
     134 * @param ucode  Top-half pseudocode handler.
     135 *
     136 * @return Value returned by the kernel.
     137 *
     138 */
     139int register_irq(int inr, int devno, int method, irq_code_t *ucode)
     140{
     141        return __SYSCALL4(SYS_IPC_REGISTER_IRQ, inr, devno, method,
     142            (sysarg_t) ucode);
     143}
     144
     145/** Unregister IRQ notification.
     146 *
     147 * @param inr   IRQ number.
     148 * @param devno Device number of the device generating inr.
     149 *
     150 * @return Value returned by the kernel.
     151 *
     152 */
     153int unregister_irq(int inr, int devno)
     154{
     155        return __SYSCALL2(SYS_IPC_UNREGISTER_IRQ, inr, devno);
     156}
     157
    129158/** @}
    130159 */
  • uspace/lib/c/generic/devman.c

    r2c577e0b r64d2b10  
    2828 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2929 */
    30  
    31  /** @addtogroup libc
     30
     31/** @addtogroup libc
    3232 * @{
    3333 */
     
    3737#include <str.h>
    3838#include <stdio.h>
    39 #include <ipc/ipc.h>
    4039#include <ipc/services.h>
    4140#include <ipc/devman.h>
     
    116115        async_set_client_connection(conn);
    117116       
    118         ipc_connect_to_me(phone, 0, 0, 0, NULL, NULL);
     117        async_connect_to_me(phone, 0, 0, 0, NULL);
    119118        async_wait_for(req, &retval);
    120119       
     
    221220        case DEVMAN_DRIVER:
    222221                if (devman_phone_driver >= 0) {
    223                         ipc_hangup(devman_phone_driver);
     222                        async_hangup(devman_phone_driver);
    224223                        devman_phone_driver = -1;
    225224                }
     
    227226        case DEVMAN_CLIENT:
    228227                if (devman_phone_client >= 0) {
    229                         ipc_hangup(devman_phone_client);
     228                        async_hangup(devman_phone_client);
    230229                        devman_phone_client = -1;
    231230                }
  • uspace/lib/c/generic/devmap.c

    r2c577e0b r64d2b10  
    2929
    3030#include <str.h>
    31 #include <ipc/ipc.h>
    3231#include <ipc/services.h>
    3332#include <ipc/ns.h>
     
    8079        case DEVMAP_DRIVER:
    8180                if (devmap_phone_driver >= 0) {
    82                         ipc_hangup(devmap_phone_driver);
     81                        async_hangup(devmap_phone_driver);
    8382                        devmap_phone_driver = -1;
    8483                }
     
    8685        case DEVMAP_CLIENT:
    8786                if (devmap_phone_client >= 0) {
    88                         ipc_hangup(devmap_phone_client);
     87                        async_hangup(devmap_phone_client);
    8988                        devmap_phone_client = -1;
    9089                }
     
    117116        async_set_client_connection(conn);
    118117       
    119         ipc_connect_to_me(phone, 0, 0, 0, NULL, NULL);
     118        async_connect_to_me(phone, 0, 0, 0, NULL);
    120119        async_wait_for(req, &retval);
    121120       
  • uspace/lib/c/generic/fibril_synch.c

    r2c577e0b r64d2b10  
    5555         */
    5656        if (atomic_get(&threads_in_ipc_wait) > 0)
    57                 ipc_poke();
     57                async_poke();
    5858}
    5959
  • uspace/lib/c/generic/io/io.c

    r2c577e0b r64d2b10  
    4141#include <bool.h>
    4242#include <malloc.h>
     43#include <async.h>
    4344#include <io/klog.h>
    4445#include <vfs/vfs.h>
     
    322323       
    323324        if (stream->phone >= 0)
    324                 ipc_hangup(stream->phone);
     325                async_hangup(stream->phone);
    325326       
    326327        if (stream->fd >= 0)
  • uspace/lib/c/generic/ipc.c

    r2c577e0b r64d2b10  
    4545#include <errno.h>
    4646#include <adt/list.h>
    47 #include <stdio.h>
    48 #include <unistd.h>
    4947#include <futex.h>
    50 #include <kernel/synch/synch.h>
    51 #include <async.h>
    5248#include <fibril.h>
    53 #include <assert.h>
    5449
    5550/**
     
    650645}
    651646
    652 /** Register IRQ notification.
    653  *
    654  * @param inr           IRQ number.
    655  * @param devno         Device number of the device generating inr.
    656  * @param method        Use this method for notifying me.
    657  * @param ucode         Top-half pseudocode handler.
    658  *
    659  * @return              Value returned by the kernel.
    660  */
    661 int ipc_register_irq(int inr, int devno, int method, irq_code_t *ucode)
    662 {
    663         return __SYSCALL4(SYS_IPC_REGISTER_IRQ, inr, devno, method,
    664             (sysarg_t) ucode);
    665 }
    666 
    667 /** Unregister IRQ notification.
    668  *
    669  * @param inr           IRQ number.
    670  * @param devno         Device number of the device generating inr.
    671  *
    672  * @return              Value returned by the kernel.
    673  */
    674 int ipc_unregister_irq(int inr, int devno)
    675 {
    676         return __SYSCALL2(SYS_IPC_UNREGISTER_IRQ, inr, devno);
    677 }
    678 
    679647/** Forward a received call to another destination.
    680648 *
  • uspace/lib/c/generic/libc.c

    r2c577e0b r64d2b10  
    4747#include <thread.h>
    4848#include <fibril.h>
    49 #include <ipc/ipc.h>
    5049#include <async.h>
    5150#include <as.h>
  • uspace/lib/c/generic/loader.c

    r2c577e0b r64d2b10  
    3333 */
    3434
    35 #include <ipc/ipc.h>
    3635#include <ipc/loader.h>
    3736#include <ipc/services.h>
     
    320319                return rc;
    321320       
    322         ipc_hangup(ldr->phone_id);
     321        async_hangup(ldr->phone_id);
    323322        ldr->phone_id = 0;
    324323        return EOK;
     
    338337void loader_abort(loader_t *ldr)
    339338{
    340         ipc_hangup(ldr->phone_id);
     339        async_hangup(ldr->phone_id);
    341340        ldr->phone_id = 0;
    342341}
  • uspace/lib/c/generic/net/icmp_api.c

    r2c577e0b r64d2b10  
    4141#include <net/modules.h>
    4242#include <net/ip_codes.h>
    43 
    4443#include <async.h>
    4544#include <sys/types.h>
    4645#include <sys/time.h>
    4746#include <errno.h>
    48 
    49 #include <ipc/ipc.h>
    5047#include <ipc/services.h>
    5148#include <ipc/icmp.h>
  • uspace/lib/c/generic/net/modules.c

    r2c577e0b r64d2b10  
    4343#include <errno.h>
    4444#include <sys/time.h>
    45 
    46 #include <ipc/ipc.h>
    4745#include <ipc/services.h>
    48 
    4946#include <net/modules.h>
    5047
     
    6764                switch (count) {
    6865                case 0:
    69                         ipc_answer_0(callid, (sysarg_t) result);
     66                        async_answer_0(callid, (sysarg_t) result);
    7067                        break;
    7168                case 1:
    72                         ipc_answer_1(callid, (sysarg_t) result,
     69                        async_answer_1(callid, (sysarg_t) result,
    7370                            IPC_GET_ARG1(*answer));
    7471                        break;
    7572                case 2:
    76                         ipc_answer_2(callid, (sysarg_t) result,
     73                        async_answer_2(callid, (sysarg_t) result,
    7774                            IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer));
    7875                        break;
    7976                case 3:
    80                         ipc_answer_3(callid, (sysarg_t) result,
     77                        async_answer_3(callid, (sysarg_t) result,
    8178                            IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
    8279                            IPC_GET_ARG3(*answer));
    8380                        break;
    8481                case 4:
    85                         ipc_answer_4(callid, (sysarg_t) result,
     82                        async_answer_4(callid, (sysarg_t) result,
    8683                            IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
    8784                            IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer));
     
    8986                case 5:
    9087                default:
    91                         ipc_answer_5(callid, (sysarg_t) result,
     88                        async_answer_5(callid, (sysarg_t) result,
    9289                            IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
    9390                            IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer),
     
    137134    sysarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout)
    138135{
    139         int rc;
    140        
    141136        /* Connect to the needed service */
    142137        int phone = connect_to_service_timeout(need, timeout);
    143138        if (phone >= 0) {
    144139                /* Request the bidirectional connection */
    145                 sysarg_t taskhash;
    146                 sysarg_t phonehash;
    147                
    148                 rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &taskhash,
    149                     &phonehash);
     140                int rc = async_connect_to_me(phone, arg1, arg2, arg3, client_receiver);
    150141                if (rc != EOK) {
    151                         ipc_hangup(phone);
     142                        async_hangup(phone);
    152143                        return rc;
    153144                }
    154                 async_new_connection(taskhash, phonehash, 0, NULL,
    155                     client_receiver);
    156145        }
    157146       
  • uspace/lib/c/generic/net/socket_client.c

    r2c577e0b r64d2b10  
    4343#include <stdlib.h>
    4444#include <errno.h>
    45 
     45#include <task.h>
    4646#include <ipc/services.h>
    4747#include <ipc/socket.h>
    48 
    4948#include <net/modules.h>
    5049#include <net/in.h>
     
    278277        }
    279278
    280         ipc_answer_0(callid, (sysarg_t) rc);
     279        async_answer_0(callid, (sysarg_t) rc);
    281280        goto loop;
    282281}
     
    687686
    688687        /* Read address */
    689         ipc_data_read_start(socket->phone, cliaddr, *addrlen);
     688        async_data_read_start(socket->phone, cliaddr, *addrlen);
    690689        fibril_rwlock_write_unlock(&socket_globals.lock);
    691690        async_wait_for(message_id, &ipc_result);
  • uspace/lib/c/generic/udebug.c

    r2c577e0b r64d2b10  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#include <udebug.h>
    3636#include <sys/types.h>
    37 #include <ipc/ipc.h>
    3837#include <async.h>
    3938
  • uspace/lib/c/generic/vfs/vfs.c

    r2c577e0b r64d2b10  
    11/*
    2  * Copyright (c) 2008 Jakub Jermar 
     2 * Copyright (c) 2008 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    4343#include <sys/stat.h>
    4444#include <sys/types.h>
    45 #include <ipc/ipc.h>
    4645#include <ipc/services.h>
    4746#include <ipc/ns.h>
Note: See TracChangeset for help on using the changeset viewer.