Changeset 6843a9c in mainline for uspace/lib/c/generic


Ignore:
Timestamp:
2012-06-29T13:02:14Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
722912e
Parents:
ba72f2b (diff), 0bbd13e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

Trivial conflicts.

Location:
uspace/lib/c/generic
Files:
6 added
4 deleted
24 edited

Legend:

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

    rba72f2b r6843a9c  
    4545/** Create address space area.
    4646 *
    47  * @param address Virtual address where to place new address space area.
    48  * @param size    Size of the area.
    49  * @param flags   Flags describing type of the area.
     47 * @param base  Starting virtual address of the area.
     48 *              If set to AS_AREA_ANY ((void *) -1),
     49 *              the kernel finds a mappable area.
     50 * @param size  Size of the area.
     51 * @param flags Flags describing type of the area.
    5052 *
    51  * @return address on success, (void *) -1 otherwise.
     53 * @return Starting virtual address of the created area on success.
     54 * @return AS_MAP_FAILED ((void *) -1) otherwise.
    5255 *
    5356 */
    54 void *as_area_create(void *address, size_t size, unsigned int flags)
     57void *as_area_create(void *base, size_t size, unsigned int flags)
    5558{
    56         return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t) address,
    57             (sysarg_t) size, (sysarg_t) flags);
     59        return (void *) __SYSCALL4(SYS_AS_AREA_CREATE, (sysarg_t) base,
     60            (sysarg_t) size, (sysarg_t) flags, (sysarg_t) __entry);
    5861}
    5962
     
    102105}
    103106
    104 /** Return pointer to unmapped address space area
     107/** Find mapping to physical address.
    105108 *
    106  * @param size Requested size of the allocation.
     109 * @param      virt Virtual address to find mapping for.
     110 * @param[out] phys Physical adress.
    107111 *
    108  * @return Pointer to the beginning of unmapped address space area.
     112 * @return EOK on no error.
     113 * @retval ENOENT if no mapping was found.
    109114 *
    110115 */
    111 void *as_get_mappable_page(size_t size)
     116int as_get_physical_mapping(const void *virt, uintptr_t *phys)
    112117{
    113         return (void *) __SYSCALL2(SYS_AS_GET_UNMAPPED_AREA,
    114             (sysarg_t) __entry, (sysarg_t) size);
    115 }
    116 
    117 /** Find mapping to physical address.
    118  *
    119  * @param address Virtual address in question (virtual).
    120  * @param[out] frame Frame address (physical).
    121  * @return Error code.
    122  * @retval EOK No error, @p frame holds the translation.
    123  * @retval ENOENT Mapping not found.
    124  */
    125 int as_get_physical_mapping(const void *address, uintptr_t *frame)
    126 {
    127         uintptr_t tmp_frame;
    128         uintptr_t virt = (uintptr_t) address;
    129        
    130         int rc = (int) __SYSCALL2(SYS_PAGE_FIND_MAPPING,
    131             (sysarg_t) virt, (sysarg_t) &tmp_frame);
    132         if (rc != EOK) {
    133                 return rc;
    134         }
    135        
    136         if (frame != NULL) {
    137                 *frame = tmp_frame;
    138         }
    139        
    140         return EOK;
     118        return (int) __SYSCALL2(SYS_PAGE_FIND_MAPPING, (sysarg_t) virt,
     119            (sysarg_t) phys);
    141120}
    142121
  • uspace/lib/c/generic/async.c

    rba72f2b r6843a9c  
    189189        /** If reply was received. */
    190190        bool done;
     191
     192        /** If the message / reply should be discarded on arrival. */
     193        bool forget;
     194
     195        /** If already destroyed. */
     196        bool destroyed;
    191197       
    192198        /** Pointer to where the answer data is stored. */
     
    241247static fibril_local connection_t *fibril_connection;
    242248
     249static void to_event_initialize(to_event_t *to)
     250{
     251        struct timeval tv = { 0, 0 };
     252
     253        to->inlist = false;
     254        to->occurred = false;
     255        link_initialize(&to->link);
     256        to->expires = tv;
     257}
     258
     259static void wu_event_initialize(wu_event_t *wu)
     260{
     261        wu->inlist = false;
     262        link_initialize(&wu->link);
     263}
     264
     265void awaiter_initialize(awaiter_t *aw)
     266{
     267        aw->fid = 0;
     268        aw->active = false;
     269        to_event_initialize(&aw->to_event);
     270        wu_event_initialize(&aw->wu_event);
     271}
     272
     273static amsg_t *amsg_create(void)
     274{
     275        amsg_t *msg;
     276
     277        msg = malloc(sizeof(amsg_t));
     278        if (msg) {
     279                msg->done = false;
     280                msg->forget = false;
     281                msg->destroyed = false;
     282                msg->dataptr = NULL;
     283                msg->retval = (sysarg_t) EINVAL;
     284                awaiter_initialize(&msg->wdata);
     285        }
     286
     287        return msg;
     288}
     289
     290static void amsg_destroy(amsg_t *msg)
     291{
     292        assert(!msg->destroyed);
     293        msg->destroyed = true;
     294        free(msg);
     295}
     296
    243297static void *default_client_data_constructor(void)
    244298{
     
    257311void async_set_client_data_constructor(async_client_data_ctor_t ctor)
    258312{
     313        assert(async_client_data_create == default_client_data_constructor);
    259314        async_client_data_create = ctor;
    260315}
     
    262317void async_set_client_data_destructor(async_client_data_dtor_t dtor)
    263318{
     319        assert(async_client_data_destroy == default_client_data_destructor);
    264320        async_client_data_destroy = dtor;
    265321}
     
    303359void async_set_client_connection(async_client_conn_t conn)
    304360{
     361        assert(client_connection == default_client_connection);
    305362        client_connection = conn;
    306363}
     
    889946       
    890947        switch (IPC_GET_IMETHOD(*call)) {
    891         case IPC_M_CONNECT_ME:
     948        case IPC_M_CLONE_ESTABLISH:
    892949        case IPC_M_CONNECT_ME_TO:
    893950                /* Open new connection with fibril, etc. */
     
    9601017               
    9611018                suseconds_t timeout;
     1019                unsigned int flags = SYNCH_FLAGS_NONE;
    9621020                if (!list_empty(&timeout_list)) {
    9631021                        awaiter_t *waiter = list_get_instance(
     
    9701028                                futex_up(&async_futex);
    9711029                                handle_expired_timeouts();
    972                                 continue;
    973                         } else
     1030                                /*
     1031                                 * Notice that even if the event(s) already
     1032                                 * expired (and thus the other fibril was
     1033                                 * supposed to be running already),
     1034                                 * we check for incoming IPC.
     1035                                 *
     1036                                 * Otherwise, a fibril that continuously
     1037                                 * creates (almost) expired events could
     1038                                 * prevent IPC retrieval from the kernel.
     1039                                 */
     1040                                timeout = 0;
     1041                                flags = SYNCH_FLAGS_NON_BLOCKING;
     1042
     1043                        } else {
    9741044                                timeout = tv_sub(&waiter->to_event.expires, &tv);
    975                 } else
     1045                                futex_up(&async_futex);
     1046                        }
     1047                } else {
     1048                        futex_up(&async_futex);
    9761049                        timeout = SYNCH_NO_TIMEOUT;
    977                
    978                 futex_up(&async_futex);
     1050                }
    9791051               
    9801052                atomic_inc(&threads_in_ipc_wait);
    9811053               
    9821054                ipc_call_t call;
    983                 ipc_callid_t callid = ipc_wait_cycle(&call, timeout,
    984                     SYNCH_FLAGS_NONE);
     1055                ipc_callid_t callid = ipc_wait_cycle(&call, timeout, flags);
    9851056               
    9861057                atomic_dec(&threads_in_ipc_wait);
     
    10971168       
    10981169        msg->done = true;
    1099         if (!msg->wdata.active) {
     1170
     1171        if (msg->forget) {
     1172                assert(msg->wdata.active);
     1173                amsg_destroy(msg);
     1174        } else if (!msg->wdata.active) {
    11001175                msg->wdata.active = true;
    11011176                fibril_add_ready(msg->wdata.fid);
    11021177        }
    1103        
     1178
    11041179        futex_up(&async_futex);
    11051180}
     
    11281203                return 0;
    11291204       
    1130         amsg_t *msg = malloc(sizeof(amsg_t));
     1205        amsg_t *msg = amsg_create();
    11311206        if (msg == NULL)
    11321207                return 0;
    11331208       
    1134         msg->done = false;
    11351209        msg->dataptr = dataptr;
    1136        
    1137         msg->wdata.to_event.inlist = false;
    1138        
    1139         /*
    1140          * We may sleep in the next method,
    1141          * but it will use its own means
    1142          */
    11431210        msg->wdata.active = true;
    11441211       
     
    11741241                return 0;
    11751242       
    1176         amsg_t *msg = malloc(sizeof(amsg_t));
    1177        
     1243        amsg_t *msg = amsg_create();
    11781244        if (msg == NULL)
    11791245                return 0;
    11801246       
    1181         msg->done = false;
    11821247        msg->dataptr = dataptr;
    1183        
    1184         msg->wdata.to_event.inlist = false;
    1185        
    1186         /*
    1187          * We may sleep in the next method,
    1188          * but it will use its own means
    1189          */
    11901248        msg->wdata.active = true;
    11911249       
     
    12101268       
    12111269        futex_down(&async_futex);
     1270
     1271        assert(!msg->forget);
     1272        assert(!msg->destroyed);
     1273
    12121274        if (msg->done) {
    12131275                futex_up(&async_futex);
     
    12281290                *retval = msg->retval;
    12291291       
    1230         free(msg);
     1292        amsg_destroy(msg);
    12311293}
    12321294
    12331295/** Wait for a message sent by the async framework, timeout variant.
     1296 *
     1297 * If the wait times out, the caller may choose to either wait again by calling
     1298 * async_wait_for() or async_wait_timeout(), or forget the message via
     1299 * async_forget().
    12341300 *
    12351301 * @param amsgid  Hash of the message to wait for.
     
    12461312       
    12471313        amsg_t *msg = (amsg_t *) amsgid;
    1248        
    1249         /* TODO: Let it go through the event read at least once */
    1250         if (timeout < 0)
    1251                 return ETIMEOUT;
    1252        
     1314
    12531315        futex_down(&async_futex);
     1316
     1317        assert(!msg->forget);
     1318        assert(!msg->destroyed);
     1319
    12541320        if (msg->done) {
    12551321                futex_up(&async_futex);
     
    12571323        }
    12581324       
     1325        /*
     1326         * Negative timeout is converted to zero timeout to avoid
     1327         * using tv_add with negative augmenter.
     1328         */
     1329        if (timeout < 0)
     1330                timeout = 0;
     1331
    12591332        gettimeofday(&msg->wdata.to_event.expires, NULL);
    12601333        tv_add(&msg->wdata.to_event.expires, timeout);
    12611334       
     1335        /*
     1336         * Current fibril is inserted as waiting regardless of the
     1337         * "size" of the timeout.
     1338         *
     1339         * Checking for msg->done and immediately bailing out when
     1340         * timeout == 0 would mean that the manager fibril would never
     1341         * run (consider single threaded program).
     1342         * Thus the IPC answer would be never retrieved from the kernel.
     1343         *
     1344         * Notice that the actual delay would be very small because we
     1345         * - switch to manager fibril
     1346         * - the manager sees expired timeout
     1347         * - and thus adds us back to ready queue
     1348         * - manager switches back to some ready fibril
     1349         *   (prior it, it checks for incoming IPC).
     1350         *
     1351         */
    12621352        msg->wdata.fid = fibril_get_id();
    12631353        msg->wdata.active = false;
     
    12761366                *retval = msg->retval;
    12771367       
    1278         free(msg);
     1368        amsg_destroy(msg);
    12791369       
    12801370        return 0;
    12811371}
     1372 
     1373/** Discard the message / reply on arrival.
     1374 *
     1375 * The message will be marked to be discarded once the reply arrives in
     1376 * reply_received(). It is not allowed to call async_wait_for() or
     1377 * async_wait_timeout() on this message after a call to this function.
     1378 *
     1379 * @param amsgid  Hash of the message to forget.
     1380 */
     1381void async_forget(aid_t amsgid)
     1382{
     1383        amsg_t *msg = (amsg_t *) amsgid;
     1384
     1385        assert(msg);
     1386        assert(!msg->forget);
     1387        assert(!msg->destroyed);
     1388
     1389        futex_down(&async_futex);
     1390        if (msg->done) {
     1391                amsg_destroy(msg);
     1392        } else {
     1393                msg->dataptr = NULL;
     1394                msg->forget = true;
     1395        }
     1396        futex_up(&async_futex);
     1397}
    12821398
    12831399/** Wait for specified time.
     
    12901406void async_usleep(suseconds_t timeout)
    12911407{
    1292         amsg_t *msg = malloc(sizeof(amsg_t));
    1293        
     1408        amsg_t *msg = amsg_create();
    12941409        if (!msg)
    12951410                return;
    12961411       
    12971412        msg->wdata.fid = fibril_get_id();
    1298         msg->wdata.active = false;
    12991413       
    13001414        gettimeofday(&msg->wdata.to_event.expires, NULL);
     
    13101424        /* Futex is up automatically after fibril_switch() */
    13111425       
    1312         free(msg);
     1426        amsg_destroy(msg);
    13131427}
    13141428
     
    15561670}
    15571671
    1558 /** Wrapper for making IPC_M_CONNECT_ME calls using the async framework.
    1559  *
    1560  * Ask through for a cloned connection to some service.
     1672/** Wrapper for making IPC_M_CLONE_ESTABLISH calls using the async framework.
     1673 *
     1674 * Ask for a cloned connection to some service.
    15611675 *
    15621676 * @param mgmt Exchange management style.
     
    15661680 *
    15671681 */
    1568 async_sess_t *async_connect_me(exch_mgmt_t mgmt, async_exch_t *exch)
     1682async_sess_t *async_clone_establish(exch_mgmt_t mgmt, async_exch_t *exch)
    15691683{
    15701684        if (exch == NULL) {
     
    15811695        ipc_call_t result;
    15821696       
    1583         amsg_t *msg = malloc(sizeof(amsg_t));
    1584         if (msg == NULL) {
     1697        amsg_t *msg = amsg_create();
     1698        if (!msg) {
    15851699                free(sess);
    15861700                errno = ENOMEM;
     
    15881702        }
    15891703       
    1590         msg->done = false;
    15911704        msg->dataptr = &result;
    1592        
    1593         msg->wdata.to_event.inlist = false;
    1594        
    1595         /*
    1596          * We may sleep in the next method,
    1597          * but it will use its own means
    1598          */
    15991705        msg->wdata.active = true;
    16001706       
    1601         ipc_call_async_0(exch->phone, IPC_M_CONNECT_ME, msg,
     1707        ipc_call_async_0(exch->phone, IPC_M_CLONE_ESTABLISH, msg,
    16021708            reply_received, true);
    16031709       
     
    16401746        ipc_call_t result;
    16411747       
    1642         amsg_t *msg = malloc(sizeof(amsg_t));
    1643         if (msg == NULL)
     1748        amsg_t *msg = amsg_create();
     1749        if (!msg)
    16441750                return ENOENT;
    16451751       
    1646         msg->done = false;
    16471752        msg->dataptr = &result;
    1648        
    1649         msg->wdata.to_event.inlist = false;
    1650        
    1651         /*
    1652          * We may sleep in the next method,
    1653          * but it will use its own means
    1654          */
    16551753        msg->wdata.active = true;
    16561754       
     
    18461944       
    18471945        fibril_mutex_lock(&async_sess_mutex);
    1848 
     1946       
    18491947        int rc = async_hangup_internal(sess->phone);
    18501948       
     
    19982096 *
    19992097 * @param exch  Exchange for sending the message.
    2000  * @param dst   Destination address space area base.
    20012098 * @param size  Size of the destination address space area.
    20022099 * @param arg   User defined argument.
    20032100 * @param flags Storage for the received flags. Can be NULL.
     2101 * @param dst   Destination address space area base. Cannot be NULL.
    20042102 *
    20052103 * @return Zero on success or a negative error code from errno.h.
    20062104 *
    20072105 */
    2008 int async_share_in_start(async_exch_t *exch, void *dst, size_t size,
    2009     sysarg_t arg, unsigned int *flags)
     2106int async_share_in_start(async_exch_t *exch, size_t size, sysarg_t arg,
     2107    unsigned int *flags, void **dst)
    20102108{
    20112109        if (exch == NULL)
    20122110                return ENOENT;
    20132111       
    2014         sysarg_t tmp_flags;
    2015         int res = async_req_3_2(exch, IPC_M_SHARE_IN, (sysarg_t) dst,
    2016             (sysarg_t) size, arg, NULL, &tmp_flags);
     2112        sysarg_t _flags = 0;
     2113        sysarg_t _dst = (sysarg_t) -1;
     2114        int res = async_req_2_4(exch, IPC_M_SHARE_IN, (sysarg_t) size,
     2115            arg, NULL, &_flags, NULL, &_dst);
    20172116       
    20182117        if (flags)
    2019                 *flags = (unsigned int) tmp_flags;
    2020        
     2118                *flags = (unsigned int) _flags;
     2119       
     2120        *dst = (void *) _dst;
    20212121        return res;
    20222122}
     
    20472147                return false;
    20482148       
    2049         *size = (size_t) IPC_GET_ARG2(data);
     2149        *size = (size_t) IPC_GET_ARG1(data);
    20502150        return true;
    20512151}
     
    20532153/** Wrapper for answering the IPC_M_SHARE_IN calls using the async framework.
    20542154 *
    2055  * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
     2155 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_IN
    20562156 * calls so that the user doesn't have to remember the meaning of each IPC
    20572157 * argument.
     
    21312231 *
    21322232 */
    2133 int async_share_out_finalize(ipc_callid_t callid, void *dst)
     2233int async_share_out_finalize(ipc_callid_t callid, void **dst)
    21342234{
    21352235        return ipc_share_out_finalize(callid, dst);
     
    22462346            IPC_FF_ROUTE_FROM_ME);
    22472347        if (retval != EOK) {
    2248                 async_wait_for(msg, NULL);
     2348                async_forget(msg);
    22492349                ipc_answer_0(callid, retval);
    22502350                return retval;
     
    24402540            IPC_FF_ROUTE_FROM_ME);
    24412541        if (retval != EOK) {
    2442                 async_wait_for(msg, NULL);
     2542                async_forget(msg);
    24432543                ipc_answer_0(callid, retval);
    24442544                return retval;
  • uspace/lib/c/generic/ddi.c

    rba72f2b r6843a9c  
    3333 */
    3434
     35#include <assert.h>
     36#include <unistd.h>
     37#include <errno.h>
    3538#include <sys/types.h>
    3639#include <abi/ddi/arg.h>
     
    4245#include <align.h>
    4346#include <libarch/config.h>
     47#include "private/libc.h"
    4448
    4549/** Return unique device number.
     
    5357}
    5458
    55 /** Map piece of physical memory to task.
     59/** Map a piece of physical memory to task.
    5660 *
    5761 * Caller of this function must have the CAP_MEM_MANAGER capability.
    5862 *
    59  * @param pf            Physical address of the starting frame.
    60  * @param vp            Virtual address of the starting page.
    61  * @param pages         Number of pages to map.
    62  * @param flags         Flags for the new address space area.
     63 * @param phys  Physical address of the starting frame.
     64 * @param pages Number of pages to map.
     65 * @param flags Flags for the new address space area.
     66 * @param virt  Virtual address of the starting page.
    6367 *
    64  * @return              0 on success, EPERM if the caller lacks the
    65  *                      CAP_MEM_MANAGER capability, ENOENT if there is no task
    66  *                      with specified ID and ENOMEM if there was some problem
    67  *                      in creating address space area.
     68 * @return EOK on success
     69 * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability
     70 * @return ENOENT if there is no task with specified ID
     71 * @return ENOMEM if there was some problem in creating
     72 *         the address space area.
     73 *
    6874 */
    69 int physmem_map(void *pf, void *vp, unsigned long pages, int flags)
     75int physmem_map(void *phys, size_t pages, unsigned int flags, void **virt)
    7076{
    71         return __SYSCALL4(SYS_PHYSMEM_MAP, (sysarg_t) pf, (sysarg_t) vp, pages,
    72             flags);
     77        return __SYSCALL5(SYS_PHYSMEM_MAP, (sysarg_t) phys,
     78            pages, flags, (sysarg_t) virt, (sysarg_t) __entry);
     79}
     80
     81int dmamem_map(void *virt, size_t size, unsigned int map_flags,
     82    unsigned int flags, void **phys)
     83{
     84        return (int) __SYSCALL6(SYS_DMAMEM_MAP, (sysarg_t) size,
     85            (sysarg_t) map_flags, (sysarg_t) flags & ~DMAMEM_FLAGS_ANONYMOUS,
     86            (sysarg_t) phys, (sysarg_t) virt, 0);
     87}
     88
     89int dmamem_map_anonymous(size_t size, unsigned int map_flags,
     90    unsigned int flags, void **phys, void **virt)
     91{
     92        return (int) __SYSCALL6(SYS_DMAMEM_MAP, (sysarg_t) size,
     93            (sysarg_t) map_flags, (sysarg_t) flags | DMAMEM_FLAGS_ANONYMOUS,
     94            (sysarg_t) phys, (sysarg_t) virt, (sysarg_t) __entry);
     95}
     96
     97int dmamem_unmap(void *virt, size_t size)
     98{
     99        return __SYSCALL3(SYS_DMAMEM_UNMAP, (sysarg_t) virt, (sysarg_t) size, 0);
     100}
     101
     102int dmamem_unmap_anonymous(void *virt)
     103{
     104        return __SYSCALL3(SYS_DMAMEM_UNMAP, (sysarg_t) virt, 0,
     105            DMAMEM_FLAGS_ANONYMOUS);
    73106}
    74107
     
    77110 * Caller of this function must have the IO_MEM_MANAGER capability.
    78111 *
    79  * @param id            Task ID.
    80  * @param ioaddr        Starting address of the I/O range.
    81  * @param size          Size of the range.
     112 * @param id     Task ID.
     113 * @param ioaddr Starting address of the I/O range.
     114 * @param size   Size of the range.
    82115 *
    83  * @return              0 on success, EPERM if the caller lacks the
    84  *                      CAP_IO_MANAGER capability, ENOENT if there is no task
    85  *                      with specified ID and ENOMEM if there was some problem
    86  *                      in allocating memory.
     116 * @return EOK on success
     117 * @return EPERM if the caller lacks the CAP_IO_MANAGER capability
     118 * @return ENOENT if there is no task with specified ID
     119 * @return ENOMEM if there was some problem in allocating memory.
     120 *
    87121 */
    88122int iospace_enable(task_id_t id, void *ioaddr, unsigned long size)
    89123{
    90124        ddi_ioarg_t arg;
    91 
     125       
    92126        arg.task_id = id;
    93127        arg.ioaddr = ioaddr;
    94128        arg.size = size;
    95 
     129       
    96130        return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg);
    97131}
     
    99133/** Enable PIO for specified I/O range.
    100134 *
    101  * @param pio_addr      I/O start address.
    102  * @param size          Size of the I/O region.
    103  * @param use_addr      Address where the final address for application's PIO
    104  *                      will be stored.
     135 * @param pio_addr I/O start address.
     136 * @param size     Size of the I/O region.
     137 * @param virt     Virtual address for application's
     138 *                 PIO operations.
    105139 *
    106  * @return              Zero on success or negative error code.
     140 * @return EOK on success.
     141 * @return Negative error code on failure.
     142 *
    107143 */
    108 int pio_enable(void *pio_addr, size_t size, void **use_addr)
     144int pio_enable(void *pio_addr, size_t size, void **virt)
    109145{
    110         void *phys;
    111         void *virt;
    112         size_t offset;
    113         unsigned int pages;
    114 
    115146#ifdef IO_SPACE_BOUNDARY
    116147        if (pio_addr < IO_SPACE_BOUNDARY) {
    117                 *use_addr = pio_addr;
     148                *virt = pio_addr;
    118149                return iospace_enable(task_get_id(), pio_addr, size);
    119150        }
    120151#endif
    121 
    122         phys = (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE);
    123         offset = pio_addr - phys;
    124         pages = ALIGN_UP(offset + size, PAGE_SIZE) >> PAGE_WIDTH;
    125         virt = as_get_mappable_page(pages << PAGE_WIDTH);
    126         *use_addr = virt + offset;
    127         return physmem_map(phys, virt, pages, AS_AREA_READ | AS_AREA_WRITE);
     152       
     153        void *phys_frame =
     154            (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE);
     155        size_t offset = pio_addr - phys_frame;
     156        size_t pages = SIZE2PAGES(offset + size);
     157       
     158        void *virt_page;
     159        int rc = physmem_map(phys_frame, pages,
     160            AS_AREA_READ | AS_AREA_WRITE, &virt_page);
     161        if (rc != EOK)
     162                return rc;
     163       
     164        *virt = virt_page + offset;
     165        return EOK;
    128166}
    129167
     
    138176 *
    139177 */
    140 int register_irq(int inr, int devno, int method, irq_code_t *ucode)
     178int irq_register(int inr, int devno, int method, irq_code_t *ucode)
    141179{
    142         return __SYSCALL4(SYS_REGISTER_IRQ, inr, devno, method,
     180        return __SYSCALL4(SYS_IRQ_REGISTER, inr, devno, method,
    143181            (sysarg_t) ucode);
    144182}
     
    152190 *
    153191 */
    154 int unregister_irq(int inr, int devno)
     192int irq_unregister(int inr, int devno)
    155193{
    156         return __SYSCALL2(SYS_UNREGISTER_IRQ, inr, devno);
     194        return __SYSCALL2(SYS_IRQ_UNREGISTER, inr, devno);
    157195}
    158196
  • uspace/lib/c/generic/device/nic.c

    rba72f2b r6843a9c  
    4444#include <ipc/services.h>
    4545
    46 /** Send a packet through the device
    47  *
    48  * @param[in] dev_sess
    49  * @param[in] packet_id Id of the sent packet
    50  *
    51  * @return EOK If the operation was successfully completed
    52  *
    53  */
    54 int nic_send_message(async_sess_t *dev_sess, packet_id_t packet_id)
    55 {
    56         async_exch_t *exch = async_exchange_begin(dev_sess);
    57         int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    58             NIC_SEND_MESSAGE, packet_id);
    59         async_exchange_end(exch);
    60        
    61         return rc;
    62 }
    63 
    64 /** Connect the driver to the NET and NIL services
    65  *
    66  * @param[in] dev_sess
    67  * @param[in] nil_service Service identifier for the NIL service
     46/** Send frame from NIC
     47 *
     48 * @param[in] dev_sess
     49 * @param[in] data     Frame data
     50 * @param[in] size     Frame size in bytes
     51 *
     52 * @return EOK If the operation was successfully completed
     53 *
     54 */
     55int nic_send_frame(async_sess_t *dev_sess, void *data, size_t size)
     56{
     57        async_exch_t *exch = async_exchange_begin(dev_sess);
     58       
     59        ipc_call_t answer;
     60        aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     61            NIC_SEND_MESSAGE, &answer);
     62        sysarg_t retval = async_data_write_start(exch, data, size);
     63       
     64        async_exchange_end(exch);
     65       
     66        if (retval != EOK) {
     67                async_forget(req);
     68                return retval;
     69        }
     70
     71        async_wait_for(req, &retval);
     72        return retval;
     73}
     74
     75/** Create callback connection from NIC service
     76 *
     77 * @param[in] dev_sess
    6878 * @param[in] device_id
    6979 *
     
    7181 *
    7282 */
    73 int nic_connect_to_nil(async_sess_t *dev_sess, services_t nil_service,
    74     nic_device_id_t device_id)
    75 {
    76         async_exch_t *exch = async_exchange_begin(dev_sess);
    77         int rc = async_req_3_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    78             NIC_CONNECT_TO_NIL, nil_service, device_id);
    79         async_exchange_end(exch);
    80        
    81         return rc;
     83int nic_callback_create(async_sess_t *dev_sess, async_client_conn_t cfun,
     84    void *carg)
     85{
     86        ipc_call_t answer;
     87        int rc;
     88        sysarg_t retval;
     89       
     90        async_exch_t *exch = async_exchange_begin(dev_sess);
     91        aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     92            NIC_CALLBACK_CREATE, &answer);
     93       
     94        rc = async_connect_to_me(exch, 0, 0, 0, cfun, carg);
     95        if (rc != EOK) {
     96                async_forget(req);
     97                return rc;
     98        }
     99        async_exchange_end(exch);
     100       
     101        async_wait_for(req, &retval);
     102        return (int) retval;
    82103}
    83104
     
    324345 * it can never force the NIC to advertise unsupported modes.
    325346 *
    326  * The allowed modes are defined in "net/eth_phys.h" in the C library.
     347 * The allowed modes are defined in "nic/eth_phys.h" in the C library.
    327348 *
    328349 * @param[in] dev_sess
     
    361382/** Probe current state of auto-negotiation.
    362383 *
    363  * Modes are defined in the "net/eth_phys.h" in the C library.
     384 * Modes are defined in the "nic/eth_phys.h" in the C library.
    364385 *
    365386 * @param[in]  dev_sess
     
    895916 *
    896917 */
    897 int nic_vlan_set_tag(async_sess_t *dev_sess, uint16_t tag, int add, int strip)
     918int nic_vlan_set_tag(async_sess_t *dev_sess, uint16_t tag, bool add, bool strip)
    898919{
    899920        async_exch_t *exch = async_exchange_begin(dev_sess);
  • uspace/lib/c/generic/devman.c

    rba72f2b r6843a9c  
    177177
    178178/** Register running driver with device manager. */
    179 int devman_driver_register(const char *name, async_client_conn_t conn)
     179int devman_driver_register(const char *name)
    180180{
    181181        async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_DRIVER);
     
    188188       
    189189        if (retval != EOK) {
    190                 async_wait_for(req, NULL);
    191                 return retval;
    192         }
    193        
    194         async_set_client_connection(conn);
     190                async_forget(req);
     191                return retval;
     192        }
    195193       
    196194        exch = devman_exchange_begin(DEVMAN_DRIVER);
    197         async_connect_to_me(exch, 0, 0, 0, conn, NULL);
     195        async_connect_to_me(exch, 0, 0, 0, NULL, NULL);
    198196        devman_exchange_end(exch);
    199197       
     
    228226        if (retval != EOK) {
    229227                devman_exchange_end(exch);
    230                 async_wait_for(req, NULL);
     228                async_forget(req);
    231229                return retval;
    232230        }
     
    244242                if (retval != EOK) {
    245243                        devman_exchange_end(exch);
    246                         async_wait_for(req2, NULL);
    247                         async_wait_for(req, NULL);
     244                        async_forget(req2);
     245                        async_forget(req);
    248246                        return retval;
    249247                }
     
    252250                if (retval != EOK) {
    253251                        devman_exchange_end(exch);
    254                         async_wait_for(req, NULL);
     252                        async_forget(req);
    255253                        return retval;
    256254                }
     
    285283       
    286284        if (retval != EOK) {
    287                 async_wait_for(req, NULL);
     285                async_forget(req);
    288286                return retval;
    289287        }
     
    388386       
    389387        if (retval != EOK) {
    390                 async_wait_for(req, NULL);
     388                async_forget(req);
    391389                return retval;
    392390        }
     
    425423       
    426424        if (dretval != EOK) {
    427                 async_wait_for(req, NULL);
     425                async_forget(req);
    428426                return dretval;
    429427        }
     
    432430        async_wait_for(req, &retval);
    433431       
    434         if (retval != EOK)
    435                 return retval;
     432        if (retval != EOK) {
     433                return retval;
     434        }
    436435       
    437436        act_size = IPC_GET_ARG2(dreply);
     
    454453}
    455454
     455int devman_fun_get_driver_name(devman_handle_t handle, char *buf, size_t buf_size)
     456{
     457        return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, buf,
     458            buf_size);
     459}
     460
    456461int devman_fun_online(devman_handle_t funh)
    457462{
     
    490495       
    491496        if (rc != EOK) {
    492                 async_wait_for(req, NULL);
     497                async_forget(req);
    493498                return rc;
    494499        }
  • uspace/lib/c/generic/elf/elf_load.c

    rba72f2b r6843a9c  
    364364         * and writeable.
    365365         */
    366         a = as_area_create((uint8_t *)base + bias, mem_sz,
     366        a = as_area_create((uint8_t *) base + bias, mem_sz,
    367367            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
    368         if (a == (void *)(-1)) {
     368        if (a == AS_MAP_FAILED) {
    369369                DPRINTF("memory mapping failed (0x%x, %d)\n",
    370                         base+bias, mem_sz);
     370                    base + bias, mem_sz);
    371371                return EE_MEMORY;
    372372        }
  • uspace/lib/c/generic/fibril.c

    rba72f2b r6843a9c  
    286286}
    287287
     288/** Delete a fibril that has never run.
     289 *
     290 * Free resources of a fibril that has been created with fibril_create()
     291 * but never readied using fibril_add_ready().
     292 *
     293 * @param fid Pointer to the fibril structure of the fibril to be
     294 *            added.
     295 */
     296void fibril_destroy(fid_t fid)
     297{
     298        fibril_t *fibril = (fibril_t *) fid;
     299       
     300        free(fibril->stack);
     301        fibril_teardown(fibril);
     302}
     303
    288304/** Add a fibril to the ready list.
    289305 *
  • uspace/lib/c/generic/fibril_synch.c

    rba72f2b r6843a9c  
    112112                awaiter_t wdata;
    113113
     114                awaiter_initialize(&wdata);
    114115                wdata.fid = fibril_get_id();
    115                 wdata.active = false;
    116116                wdata.wu_event.inlist = true;
    117                 link_initialize(&wdata.wu_event.link);
    118117                list_append(&wdata.wu_event.link, &fm->waiters);
    119118                check_for_deadlock(&fm->oi);
     
    205204                awaiter_t wdata;
    206205
     206                awaiter_initialize(&wdata);
    207207                wdata.fid = (fid_t) f;
    208                 wdata.active = false;
    209208                wdata.wu_event.inlist = true;
    210                 link_initialize(&wdata.wu_event.link);
    211209                f->flags &= ~FIBRIL_WRITER;
    212210                list_append(&wdata.wu_event.link, &frw->waiters);
     
    233231                awaiter_t wdata;
    234232
     233                awaiter_initialize(&wdata);
    235234                wdata.fid = (fid_t) f;
    236                 wdata.active = false;
    237235                wdata.wu_event.inlist = true;
    238                 link_initialize(&wdata.wu_event.link);
    239236                f->flags |= FIBRIL_WRITER;
    240237                list_append(&wdata.wu_event.link, &frw->waiters);
     
    375372                return ETIMEOUT;
    376373
     374        awaiter_initialize(&wdata);
    377375        wdata.fid = fibril_get_id();
    378         wdata.active = false;
    379        
    380376        wdata.to_event.inlist = timeout > 0;
    381         wdata.to_event.occurred = false;
    382         link_initialize(&wdata.to_event.link);
    383 
    384377        wdata.wu_event.inlist = true;
    385         link_initialize(&wdata.wu_event.link);
    386378
    387379        futex_down(&async_futex);
     
    447439}
    448440
     441/** Timer fibril.
     442 *
     443 * @param arg   Timer
     444 */
     445static int fibril_timer_func(void *arg)
     446{
     447        fibril_timer_t *timer = (fibril_timer_t *) arg;
     448        int rc;
     449
     450        fibril_mutex_lock(&timer->lock);
     451
     452        while (true) {
     453                while (timer->state != fts_active &&
     454                    timer->state != fts_cleanup) {
     455
     456                        if (timer->state == fts_cleanup)
     457                                break;
     458
     459                        fibril_condvar_wait(&timer->cv, &timer->lock);
     460                }
     461
     462                if (timer->state == fts_cleanup)
     463                        break;
     464
     465                rc = fibril_condvar_wait_timeout(&timer->cv, &timer->lock,
     466                    timer->delay);
     467                if (rc == ETIMEOUT) {
     468                        timer->state = fts_fired;
     469                        fibril_mutex_unlock(&timer->lock);
     470                        timer->fun(timer->arg);
     471                        fibril_mutex_lock(&timer->lock);
     472                }
     473        }
     474
     475        fibril_mutex_unlock(&timer->lock);
     476        return 0;
     477}
     478
     479/** Create new timer.
     480 *
     481 * @return              New timer on success, @c NULL if out of memory.
     482 */
     483fibril_timer_t *fibril_timer_create(void)
     484{
     485        fid_t fid;
     486        fibril_timer_t *timer;
     487
     488        timer = calloc(1, sizeof(fibril_timer_t));
     489        if (timer == NULL)
     490                return NULL;
     491
     492        fid = fibril_create(fibril_timer_func, (void *) timer);
     493        if (fid == 0) {
     494                free(timer);
     495                return NULL;
     496        }
     497
     498        fibril_mutex_initialize(&timer->lock);
     499        fibril_condvar_initialize(&timer->cv);
     500
     501        timer->fibril = fid;
     502        timer->state = fts_not_set;
     503
     504        fibril_add_ready(fid);
     505
     506        return timer;
     507}
     508
     509/** Destroy timer.
     510 *
     511 * @param timer         Timer, must not be active or accessed by other threads.
     512 */
     513void fibril_timer_destroy(fibril_timer_t *timer)
     514{
     515        fibril_mutex_lock(&timer->lock);
     516        assert(timer->state != fts_active);
     517        timer->state = fts_cleanup;
     518        fibril_condvar_broadcast(&timer->cv);
     519        fibril_mutex_unlock(&timer->lock);
     520}
     521
     522/** Set timer.
     523 *
     524 * Set timer to execute a callback function after the specified
     525 * interval.
     526 *
     527 * @param timer         Timer
     528 * @param delay         Delay in microseconds
     529 * @param fun           Callback function
     530 * @param arg           Argument for @a fun
     531 */
     532void fibril_timer_set(fibril_timer_t *timer, suseconds_t delay,
     533    fibril_timer_fun_t fun, void *arg)
     534{
     535        fibril_mutex_lock(&timer->lock);
     536        timer->state = fts_active;
     537        timer->delay = delay;
     538        timer->fun = fun;
     539        timer->arg = arg;
     540        fibril_condvar_broadcast(&timer->cv);
     541        fibril_mutex_unlock(&timer->lock);
     542}
     543
     544/** Clear timer.
     545 *
     546 * Clears (cancels) timer and returns last state of the timer.
     547 * This can be one of:
     548 *    - fts_not_set     If the timer has not been set or has been cleared
     549 *    - fts_active      Timer was set but did not fire
     550 *    - fts_fired       Timer fired
     551 *
     552 * @param timer         Timer
     553 * @return              Last timer state
     554 */
     555fibril_timer_state_t fibril_timer_clear(fibril_timer_t *timer)
     556{
     557        fibril_timer_state_t old_state;
     558
     559        fibril_mutex_lock(&timer->lock);
     560        old_state = timer->state;
     561        timer->state = fts_not_set;
     562
     563        timer->delay = 0;
     564        timer->fun = NULL;
     565        timer->arg = NULL;
     566        fibril_condvar_broadcast(&timer->cv);
     567        fibril_mutex_unlock(&timer->lock);
     568
     569        return old_state;
     570}
     571
    449572/** @}
    450573 */
  • uspace/lib/c/generic/io/printf_core.c

    rba72f2b r6843a9c  
    283283        /* Print leading spaces. */
    284284        size_t strw = str_length(str);
    285         if (precision == 0)
     285        if ((precision == 0) || (precision > strw))
    286286                precision = strw;
    287287       
     
    331331        /* Print leading spaces. */
    332332        size_t strw = wstr_length(str);
    333         if (precision == 0)
     333        if ((precision == 0) || (precision > strw))
    334334                precision = strw;
    335335       
  • uspace/lib/c/generic/ipc.c

    rba72f2b r6843a9c  
    4848#include <fibril.h>
    4949#include <macros.h>
     50#include "private/libc.h"
    5051
    5152/**
     
    646647 *
    647648 */
    648 int ipc_connect_me(int phoneid)
     649int ipc_clone_establish(int phoneid)
    649650{
    650651        sysarg_t newphid;
    651         int res = ipc_call_sync_0_5(phoneid, IPC_M_CONNECT_ME, NULL, NULL,
    652             NULL, NULL, &newphid);
     652        int res = ipc_call_sync_0_5(phoneid, IPC_M_CLONE_ESTABLISH, NULL,
     653            NULL, NULL, NULL, &newphid);
    653654        if (res)
    654655                return res;
     
    760761 *
    761762 * @param phoneid Phone that will be used to contact the receiving side.
    762  * @param dst     Destination address space area base.
    763763 * @param size    Size of the destination address space area.
    764764 * @param arg     User defined argument.
    765765 * @param flags   Storage for received flags. Can be NULL.
     766 * @param dst     Destination address space area base. Cannot be NULL.
    766767 *
    767768 * @return Zero on success or a negative error code from errno.h.
    768769 *
    769770 */
    770 int ipc_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg,
    771     unsigned int *flags)
    772 {
    773         sysarg_t tmp_flags = 0;
    774         int res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst,
    775             (sysarg_t) size, arg, NULL, &tmp_flags);
     771int ipc_share_in_start(int phoneid, size_t size, sysarg_t arg,
     772    unsigned int *flags, void **dst)
     773{
     774        sysarg_t _flags = 0;
     775        sysarg_t _dst = (sysarg_t) -1;
     776        int res = ipc_call_sync_2_4(phoneid, IPC_M_SHARE_IN, (sysarg_t) size,
     777            arg, NULL, &_flags, NULL, &_dst);
    776778       
    777779        if (flags)
    778                 *flags = (unsigned int) tmp_flags;
    779        
     780                *flags = (unsigned int) _flags;
     781       
     782        *dst = (void *) _dst;
    780783        return res;
    781784}
     
    783786/** Wrapper for answering the IPC_M_SHARE_IN calls.
    784787 *
    785  * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
     788 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_IN
    786789 * calls so that the user doesn't have to remember the meaning of each
    787790 * IPC argument.
     
    796799int ipc_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags)
    797800{
    798         return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) flags);
     801        return ipc_answer_3(callid, EOK, (sysarg_t) src, (sysarg_t) flags,
     802            (sysarg_t) __entry);
    799803}
    800804
     
    826830 *
    827831 */
    828 int ipc_share_out_finalize(ipc_callid_t callid, void *dst)
    829 {
    830         return ipc_answer_1(callid, EOK, (sysarg_t) dst);
     832int ipc_share_out_finalize(ipc_callid_t callid, void **dst)
     833{
     834        return ipc_answer_2(callid, EOK, (sysarg_t) __entry, (sysarg_t) dst);
    831835}
    832836
  • uspace/lib/c/generic/loader.c

    rba72f2b r6843a9c  
    101101       
    102102        if (rc != EOK) {
    103                 async_wait_for(req, NULL);
     103                async_forget(req);
    104104                return (int) rc;
    105105        }
     
    139139       
    140140        if (rc != EOK) {
    141                 async_wait_for(req, NULL);
     141                async_forget(req);
    142142                return (int) rc;
    143143        }
     
    177177       
    178178        if (rc != EOK) {
    179                 async_wait_for(req, NULL);
     179                async_forget(req);
    180180                return (int) rc;
    181181        }
     
    236236       
    237237        if (rc != EOK) {
    238                 async_wait_for(req, NULL);
     238                async_forget(req);
    239239                return (int) rc;
    240240        }
     
    281281
    282282        if (rc != EOK) {
    283                 async_wait_for(req, NULL);
     283                async_forget(req);
    284284                return (int) rc;
    285285        }
  • uspace/lib/c/generic/loc.c

    rba72f2b r6843a9c  
    4747static FIBRIL_MUTEX_INITIALIZE(loc_callback_mutex);
    4848static bool loc_callback_created = false;
     49static loc_cat_change_cb_t cat_change_cb = NULL;
    4950
    5051static async_sess_t *loc_supp_block_sess = NULL;
     
    5455static async_sess_t *loc_consumer_sess = NULL;
    5556
    56 static loc_cat_change_cb_t cat_change_cb = NULL;
    57 
    5857static void loc_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    5958{
    60         loc_cat_change_cb_t cb_fun;
    61        
    6259        while (true) {
    6360                ipc_call_t call;
     
    6966                }
    7067               
    71                 int retval;
    72                
    7368                switch (IPC_GET_IMETHOD(call)) {
    7469                case LOC_EVENT_CAT_CHANGE:
    7570                        fibril_mutex_lock(&loc_callback_mutex);
    76                         cb_fun = cat_change_cb;
    77                         if (cb_fun != NULL) {
     71                        loc_cat_change_cb_t cb_fun = cat_change_cb;
     72                        fibril_mutex_unlock(&loc_callback_mutex);
     73                       
     74                        async_answer_0(callid, EOK);
     75                       
     76                        if (cb_fun != NULL)
    7877                                (*cb_fun)();
    79                         }
    80                         fibril_mutex_unlock(&loc_callback_mutex);
    81                         retval = 0;
     78                       
    8279                        break;
    8380                default:
    84                         retval = ENOTSUP;
     81                        async_answer_0(callid, ENOTSUP);
    8582                }
    86                
    87                 async_answer_0(callid, retval);
    8883        }
    8984}
     
    10196}
    10297
     98/** Create callback
     99 *
     100 * Must be called with loc_callback_mutex locked.
     101 *
     102 * @return EOK on success.
     103 *
     104 */
    103105static int loc_callback_create(void)
    104106{
    105         async_exch_t *exch;
    106         sysarg_t retval;
    107         int rc = EOK;
    108 
    109         fibril_mutex_lock(&loc_callback_mutex);
    110        
    111107        if (!loc_callback_created) {
    112                 exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
     108                async_exch_t *exch =
     109                    loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
    113110               
    114111                ipc_call_t answer;
    115112                aid_t req = async_send_0(exch, LOC_CALLBACK_CREATE, &answer);
    116                 async_connect_to_me(exch, 0, 0, 0, loc_cb_conn, NULL);
     113                int rc = async_connect_to_me(exch, 0, 0, 0, loc_cb_conn, NULL);
    117114                loc_exchange_end(exch);
    118115               
     116                if (rc != EOK)
     117                        return rc;
     118               
     119                sysarg_t retval;
    119120                async_wait_for(req, &retval);
    120                 if (rc != EOK)
    121                         goto done;
    122                
    123                 if (retval != EOK) {
    124                         rc = retval;
    125                         goto done;
    126                 }
     121                if (retval != EOK)
     122                        return retval;
    127123               
    128124                loc_callback_created = true;
    129125        }
    130126       
    131         rc = EOK;
    132 done:
    133         fibril_mutex_unlock(&loc_callback_mutex);
    134         return rc;
     127        return EOK;
    135128}
    136129
     
    242235
    243236/** Register new driver with loc. */
    244 int loc_server_register(const char *name, async_client_conn_t conn)
     237int loc_server_register(const char *name)
    245238{
    246239        async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_SUPPLIER);
     
    253246       
    254247        if (retval != EOK) {
    255                 async_wait_for(req, NULL);
    256                 return retval;
    257         }
    258        
    259         async_set_client_connection(conn);
     248                async_forget(req);
     249                return retval;
     250        }
    260251       
    261252        exch = loc_exchange_begin(LOC_PORT_SUPPLIER);
     
    294285       
    295286        if (retval != EOK) {
    296                 async_wait_for(req, NULL);
     287                async_forget(req);
    297288                return retval;
    298289        }
     
    361352       
    362353        if (retval != EOK) {
    363                 async_wait_for(req, NULL);
     354                async_forget(req);
    364355                return retval;
    365356        }
     
    410401       
    411402        if (dretval != EOK) {
    412                 async_wait_for(req, NULL);
     403                async_forget(req);
    413404                return dretval;
    414405        }
     
    457448{
    458449        return loc_get_name_internal(LOC_SERVICE_GET_NAME, svc_id, name);
     450}
     451
     452/** Get service server name.
     453 *
     454 * Provided ID of a service, return the name of its server.
     455 *
     456 * @param svc_id        Service ID
     457 * @param name          Place to store pointer to new string. Caller should
     458 *                      free it using free().
     459 * @return              EOK on success or negative error code
     460 */
     461int loc_service_get_server_name(service_id_t svc_id, char **name)
     462{
     463        return loc_get_name_internal(LOC_SERVICE_GET_SERVER_NAME, svc_id, name);
    459464}
    460465
     
    480485       
    481486        if (retval != EOK) {
    482                 async_wait_for(req, NULL);
     487                async_forget(req);
    483488                return retval;
    484489        }
     
    529534       
    530535        if (retval != EOK) {
    531                 async_wait_for(req, NULL);
     536                async_forget(req);
    532537                return retval;
    533538        }
     
    692697               
    693698                if (rc != EOK) {
    694                         async_wait_for(req, NULL);
     699                        async_forget(req);
    695700                        free(devs);
    696701                        return 0;
     
    741746               
    742747                if (rc != EOK) {
    743                         async_wait_for(req, NULL);
     748                        async_forget(req);
    744749                        free(devs);
    745750                        return 0;
     
    769774       
    770775        if (rc != EOK) {
    771                 async_wait_for(req, NULL);
     776                async_forget(req);
    772777                return rc;
    773778        }
     
    797802    sysarg_t **data, size_t *count)
    798803{
    799         service_id_t *ids;
    800         size_t act_size;
    801         size_t alloc_size;
    802         int rc;
    803 
    804804        *data = NULL;
    805         act_size = 0;   /* silence warning */
    806 
    807         rc = loc_category_get_ids_once(method, arg1, NULL, 0,
     805        *count = 0;
     806       
     807        size_t act_size = 0;
     808        int rc = loc_category_get_ids_once(method, arg1, NULL, 0,
    808809            &act_size);
    809810        if (rc != EOK)
    810811                return rc;
    811 
    812         alloc_size = act_size;
    813         ids = malloc(alloc_size);
     812       
     813        size_t alloc_size = act_size;
     814        service_id_t *ids = malloc(alloc_size);
    814815        if (ids == NULL)
    815816                return ENOMEM;
    816 
     817       
    817818        while (true) {
    818819                rc = loc_category_get_ids_once(method, arg1, ids, alloc_size,
     
    820821                if (rc != EOK)
    821822                        return rc;
    822 
     823               
    823824                if (act_size <= alloc_size)
    824825                        break;
    825 
    826                 alloc_size *= 2;
    827                 free(ids);
    828 
    829                 ids = malloc(alloc_size);
     826               
     827                alloc_size = act_size;
     828                ids = realloc(ids, alloc_size);
    830829                if (ids == NULL)
    831830                        return ENOMEM;
    832831        }
    833 
     832       
    834833        *count = act_size / sizeof(category_id_t);
    835834        *data = ids;
     
    869868int loc_register_cat_change_cb(loc_cat_change_cb_t cb_fun)
    870869{
    871         if (loc_callback_create() != EOK)
     870        fibril_mutex_lock(&loc_callback_mutex);
     871        if (loc_callback_create() != EOK) {
     872                fibril_mutex_unlock(&loc_callback_mutex);
    872873                return EIO;
    873 
     874        }
     875       
    874876        cat_change_cb = cb_fun;
     877        fibril_mutex_unlock(&loc_callback_mutex);
     878       
    875879        return EOK;
    876880}
  • uspace/lib/c/generic/malloc.c

    rba72f2b r6843a9c  
    283283static bool area_create(size_t size)
    284284{
    285         void *start = as_get_mappable_page(size);
    286         if (start == NULL)
    287                 return false;
    288        
    289         /* Align the heap area on page boundary */
    290         void *astart = (void *) ALIGN_UP((uintptr_t) start, PAGE_SIZE);
     285        /* Align the heap area size on page boundary */
    291286        size_t asize = ALIGN_UP(size, PAGE_SIZE);
    292        
    293         astart = as_area_create(astart, asize, AS_AREA_WRITE | AS_AREA_READ);
    294         if (astart == (void *) -1)
     287        void *astart = as_area_create(AS_AREA_ANY, asize,
     288            AS_AREA_WRITE | AS_AREA_READ);
     289        if (astart == AS_MAP_FAILED)
    295290                return false;
    296291       
  • uspace/lib/c/generic/mman.c

    rba72f2b r6843a9c  
    4242{
    4343        if (!start)
    44                 start = as_get_mappable_page(length);
     44                start = AS_AREA_ANY;
    4545       
    4646//      if (!((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE)))
  • uspace/lib/c/generic/net/socket_client.c

    rba72f2b r6843a9c  
    4444#include <errno.h>
    4545#include <task.h>
     46#include <ns.h>
    4647#include <ipc/services.h>
    4748#include <ipc/socket.h>
    48 #include <net/modules.h>
    4949#include <net/in.h>
    5050#include <net/socket.h>
     
    283283static async_sess_t *socket_get_tcp_sess(void)
    284284{
    285         if (socket_globals.tcp_sess == NULL) {
    286                 socket_globals.tcp_sess = bind_service(SERVICE_TCP,
     285        if (socket_globals.tcp_sess == NULL)
     286                socket_globals.tcp_sess = service_bind(SERVICE_TCP,
    287287                    0, 0, SERVICE_TCP, socket_connection);
    288         }
    289 
     288       
    290289        return socket_globals.tcp_sess;
    291290}
     
    300299static async_sess_t *socket_get_udp_sess(void)
    301300{
    302         if (socket_globals.udp_sess == NULL) {
    303                 socket_globals.udp_sess = bind_service(SERVICE_UDP,
     301        if (socket_globals.udp_sess == NULL)
     302                socket_globals.udp_sess = service_bind(SERVICE_UDP,
    304303                    0, 0, SERVICE_UDP, socket_connection);
    305         }
    306 
     304       
    307305        return socket_globals.udp_sess;
    308306}
     
    378376 * @return              Other error codes as defined for the NET_SOCKET message.
    379377 * @return              Other error codes as defined for the
    380  *                      bind_service() function.
     378 *                      service_bind() function.
    381379 */
    382380int socket(int domain, int type, int protocol)
  • uspace/lib/c/generic/ns.c

    rba72f2b r6843a9c  
    3737#include <async.h>
    3838#include <macros.h>
     39#include <errno.h>
    3940#include "private/ns.h"
    4041
     
    4849}
    4950
    50 async_sess_t *service_connect(exch_mgmt_t mgmt, sysarg_t service, sysarg_t arg2,
     51async_sess_t *service_connect(exch_mgmt_t mgmt, services_t service, sysarg_t arg2,
    5152    sysarg_t arg3)
    5253{
     
    7273}
    7374
    74 async_sess_t *service_connect_blocking(exch_mgmt_t mgmt, sysarg_t service,
     75async_sess_t *service_connect_blocking(exch_mgmt_t mgmt, services_t service,
    7576    sysarg_t arg2, sysarg_t arg3)
    7677{
     
    8182            async_connect_me_to_blocking(mgmt, exch, service, arg2, arg3);
    8283        async_exchange_end(exch);
    83 
     84       
    8485        if (!sess)
    8586                return NULL;
     
    9192         */
    9293        async_sess_args_set(sess, arg2, arg3, 0);
     94       
     95        return sess;
     96}
     97
     98/** Create bidirectional connection with a service
     99 *
     100 * @param[in] service         Service.
     101 * @param[in] arg1            First parameter.
     102 * @param[in] arg2            Second parameter.
     103 * @param[in] arg3            Third parameter.
     104 * @param[in] client_receiver Message receiver.
     105 *
     106 * @return Session to the service.
     107 * @return Other error codes as defined by async_connect_to_me().
     108 *
     109 */
     110async_sess_t *service_bind(services_t service, sysarg_t arg1, sysarg_t arg2,
     111    sysarg_t arg3, async_client_conn_t client_receiver)
     112{
     113        /* Connect to the needed service */
     114        async_sess_t *sess =
     115            service_connect_blocking(EXCHANGE_SERIALIZE, service, 0, 0);
     116        if (sess != NULL) {
     117                /* Request callback connection */
     118                async_exch_t *exch = async_exchange_begin(sess);
     119                int rc = async_connect_to_me(exch, arg1, arg2, arg3,
     120                    client_receiver, NULL);
     121                async_exchange_end(exch);
     122               
     123                if (rc != EOK) {
     124                        async_hangup(sess);
     125                        errno = rc;
     126                        return NULL;
     127                }
     128        }
    93129       
    94130        return sess;
  • uspace/lib/c/generic/private/async.h

    rba72f2b r6843a9c  
    8181} awaiter_t;
    8282
     83extern void awaiter_initialize(awaiter_t *);
     84
    8385extern void __async_init(void);
    8486extern void async_insert_timeout(awaiter_t *);
  • uspace/lib/c/generic/stacktrace.c

    rba72f2b r6843a9c  
    3838#include <sys/types.h>
    3939#include <errno.h>
     40#include <unistd.h>
    4041
    4142static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data);
  • uspace/lib/c/generic/stats.c

    rba72f2b r6843a9c  
    4040#include <inttypes.h>
    4141#include <malloc.h>
     42#include <unistd.h>
    4243
    4344#define SYSINFO_STATS_MAX_PATH  64
  • uspace/lib/c/generic/str.c

    rba72f2b r6843a9c  
    4646#include <mem.h>
    4747#include <str.h>
     48
     49/** Check the condition if wchar_t is signed */
     50#ifdef WCHAR_IS_UNSIGNED
     51        #define WCHAR_SIGNED_CHECK(cond)  (true)
     52#else
     53        #define WCHAR_SIGNED_CHECK(cond)  (cond)
     54#endif
    4855
    4956/** Byte mask consisting of lowest @n bits (out of 8) */
     
    261268}
    262269
     270/** Get size of string with size limit.
     271 *
     272 * Get the number of bytes which are used by the string @a str
     273 * (excluding the NULL-terminator), but no more than @max_size bytes.
     274 *
     275 * @param str      String to consider.
     276 * @param max_size Maximum number of bytes to measure.
     277 *
     278 * @return Number of bytes used by the string
     279 *
     280 */
     281size_t str_nsize(const char *str, size_t max_size)
     282{
     283        size_t size = 0;
     284       
     285        while ((*str++ != 0) && (size < max_size))
     286                size++;
     287       
     288        return size;
     289}
     290
     291/** Get size of wide string with size limit.
     292 *
     293 * Get the number of bytes which are used by the wide string @a str
     294 * (excluding the NULL-terminator), but no more than @max_size bytes.
     295 *
     296 * @param str      Wide string to consider.
     297 * @param max_size Maximum number of bytes to measure.
     298 *
     299 * @return Number of bytes used by the wide string
     300 *
     301 */
     302size_t wstr_nsize(const wchar_t *str, size_t max_size)
     303{
     304        return (wstr_nlength(str, max_size) * sizeof(wchar_t));
     305}
     306
    263307/** Get size of wide string with length limit.
    264308 *
     
    362406bool ascii_check(wchar_t ch)
    363407{
    364         if ((ch >= 0) && (ch <= 127))
     408        if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127))
    365409                return true;
    366410       
     
    375419bool chr_check(wchar_t ch)
    376420{
    377         if ((ch >= 0) && (ch <= 1114111))
     421        if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111))
    378422                return true;
    379423       
     
    476520 * @param count Size of the destination buffer (must be > 0).
    477521 * @param src   Source string.
     522 *
    478523 */
    479524void str_cpy(char *dest, size_t size, const char *src)
     
    508553 * @param src   Source string.
    509554 * @param n     Maximum number of bytes to read from @a src.
     555 *
    510556 */
    511557void str_ncpy(char *dest, size_t size, const char *src, size_t n)
     
    839885       
    840886        return NULL;
     887}
     888
     889/** Removes specified trailing characters from a string.
     890 *
     891 * @param str String to remove from.
     892 * @param ch  Character to remove.
     893 */
     894void str_rtrim(char *str, wchar_t ch)
     895{
     896        size_t off = 0;
     897        size_t pos = 0;
     898        wchar_t c;
     899        bool update_last_chunk = true;
     900        char *last_chunk = NULL;
     901
     902        while ((c = str_decode(str, &off, STR_NO_LIMIT))) {
     903                if (c != ch) {
     904                        update_last_chunk = true;
     905                        last_chunk = NULL;
     906                } else if (update_last_chunk) {
     907                        update_last_chunk = false;
     908                        last_chunk = (str + pos);
     909                }
     910                pos = off;
     911        }
     912
     913        if (last_chunk)
     914                *last_chunk = '\0';
     915}
     916
     917/** Removes specified leading characters from a string.
     918 *
     919 * @param str String to remove from.
     920 * @param ch  Character to remove.
     921 */
     922void str_ltrim(char *str, wchar_t ch)
     923{
     924        wchar_t acc;
     925        size_t off = 0;
     926        size_t pos = 0;
     927        size_t str_sz = str_size(str);
     928
     929        while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) {
     930                if (acc != ch)
     931                        break;
     932                else
     933                        pos = off;
     934        }
     935
     936        if (pos > 0) {
     937                memmove(str, &str[pos], str_sz - pos);
     938                pos = str_sz - pos;
     939                str[str_sz - pos] = '\0';
     940        }
    841941}
    842942
     
    14441544 *
    14451545 */
    1446 int str_uint64(const char *nptr, char **endptr, unsigned int base,
     1546int str_uint64_t(const char *nptr, char **endptr, unsigned int base,
    14471547    bool strict, uint64_t *result)
    14481548{
  • uspace/lib/c/generic/sysinfo.c

    rba72f2b r6843a9c  
    3939#include <malloc.h>
    4040#include <bool.h>
     41#include <unistd.h>
     42
     43/** Get sysinfo keys size
     44 *
     45 * @param path  Sysinfo path.
     46 * @param value Pointer to store the keys size.
     47 *
     48 * @return EOK if the keys were successfully read.
     49 *
     50 */
     51static int sysinfo_get_keys_size(const char *path, size_t *size)
     52{
     53        return (int) __SYSCALL3(SYS_SYSINFO_GET_KEYS_SIZE, (sysarg_t) path,
     54            (sysarg_t) str_size(path), (sysarg_t) size);
     55}
     56
     57/** Get sysinfo keys
     58 *
     59 * @param path  Sysinfo path.
     60 * @param value Pointer to store the keys size.
     61 *
     62 * @return Keys read from sysinfo or NULL if the
     63 *         sysinfo item has no subkeys.
     64 *         The returned non-NULL pointer should be
     65 *         freed by free().
     66 *
     67 */
     68char *sysinfo_get_keys(const char *path, size_t *size)
     69{
     70        /*
     71         * The size of the keys might change during time.
     72         * Unfortunatelly we cannot allocate the buffer
     73         * and transfer the keys as a single atomic operation.
     74         */
     75       
     76        /* Get the keys size */
     77        int ret = sysinfo_get_keys_size(path, size);
     78        if ((ret != EOK) || (size == 0)) {
     79                /*
     80                 * Item with no subkeys.
     81                 */
     82                *size = 0;
     83                return NULL;
     84        }
     85       
     86        char *data = malloc(*size);
     87        if (data == NULL) {
     88                *size = 0;
     89                return NULL;
     90        }
     91       
     92        /* Get the data */
     93        size_t sz;
     94        ret = __SYSCALL5(SYS_SYSINFO_GET_KEYS, (sysarg_t) path,
     95            (sysarg_t) str_size(path), (sysarg_t) data, (sysarg_t) *size,
     96            (sysarg_t) &sz);
     97        if (ret == EOK) {
     98                *size = sz;
     99                return data;
     100        }
     101       
     102        free(data);
     103        *size = 0;
     104        return NULL;
     105}
    41106
    42107/** Get sysinfo item type
     
    70135/** Get sysinfo binary data size
    71136 *
    72  * @param path  Sysinfo path.
    73  * @param value Pointer to store the binary data size.
     137 * @param path Sysinfo path.
     138 * @param size Pointer to store the binary data size.
    74139 *
    75140 * @return EOK if the value was successfully read and
     
    85150/** Get sysinfo binary data
    86151 *
    87  * @param path  Sysinfo path.
    88  * @param value Pointer to store the binary data size.
     152 * @param path Sysinfo path.
     153 * @param size Pointer to store the binary data size.
    89154 *
    90155 * @return Binary data read from sysinfo or NULL if the
     
    134199}
    135200
     201/** Get sysinfo property
     202 *
     203 * @param path Sysinfo path.
     204 * @param name Property name.
     205 * @param size Pointer to store the binary data size.
     206 *
     207 * @return Property value read from sysinfo or NULL if the
     208 *         sysinfo item value type is not binary data.
     209 *         The returned non-NULL pointer should be
     210 *         freed by free().
     211 *
     212 */
     213void *sysinfo_get_property(const char *path, const char *name, size_t *size)
     214{
     215        size_t total_size;
     216        void *data = sysinfo_get_data(path, &total_size);
     217        if ((data == NULL) || (total_size == 0)) {
     218                *size = 0;
     219                return NULL;
     220        }
     221       
     222        size_t pos = 0;
     223        while (pos < total_size) {
     224                /* Process each property with sanity checks */
     225                size_t cur_size = str_nsize(data + pos, total_size - pos);
     226                if (((char *) data)[pos + cur_size] != 0)
     227                        break;
     228               
     229                bool found = (str_cmp(data + pos, name) == 0);
     230               
     231                pos += cur_size + 1;
     232                if (pos >= total_size)
     233                        break;
     234               
     235                /* Process value size */
     236                size_t value_size;
     237                memcpy(&value_size, data + pos, sizeof(value_size));
     238               
     239                pos += sizeof(value_size);
     240                if ((pos >= total_size) || (pos + value_size > total_size))
     241                        break;
     242               
     243                if (found) {
     244                        void *value = malloc(value_size);
     245                        if (value == NULL)
     246                                break;
     247                       
     248                        memcpy(value, data + pos, value_size);
     249                        free(data);
     250                       
     251                        *size = value_size;
     252                        return value;
     253                }
     254               
     255                pos += value_size;
     256        }
     257       
     258        free(data);
     259       
     260        *size = 0;
     261        return NULL;
     262}
     263
    136264/** @}
    137265 */
  • uspace/lib/c/generic/thread.c

    rba72f2b r6843a9c  
    4141#include <str.h>
    4242#include <async.h>
     43#include <errno.h>
     44#include <as.h>
    4345#include "private/thread.h"
    4446
    45 #ifndef THREAD_INITIAL_STACK_PAGES_NO
    46 #define THREAD_INITIAL_STACK_PAGES_NO   2
     47#ifndef THREAD_INITIAL_STACK_PAGES
     48        #define THREAD_INITIAL_STACK_PAGES  2
    4749#endif
    4850
     
    6567       
    6668        uarg->uspace_thread_function(uarg->uspace_thread_arg);
    67         /* XXX: we cannot free the userspace stack while running on it
    68                 free(uarg->uspace_stack);
    69                 free(uarg);
    70         */
     69        /*
     70         * XXX: we cannot free the userspace stack while running on it
     71         *
     72         * free(uarg->uspace_stack);
     73         * free(uarg);
     74         */
    7175       
    7276        /* If there is a manager, destroy it */
     
    9296    thread_id_t *tid)
    9397{
    94         char *stack;
    95         uspace_arg_t *uarg;
    96         int rc;
    97 
    98         stack = (char *) malloc(getpagesize() * THREAD_INITIAL_STACK_PAGES_NO);
    99         if (!stack)
    100                 return -1;
    101                
    102         uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t));
    103         if (!uarg) {
    104                 free(stack);
    105                 return -1;
     98        uspace_arg_t *uarg =
     99            (uspace_arg_t *) malloc(sizeof(uspace_arg_t));
     100        if (!uarg)
     101                return ENOMEM;
     102       
     103        size_t stack_size = getpagesize() * THREAD_INITIAL_STACK_PAGES;
     104        void *stack = as_area_create(AS_AREA_ANY, stack_size,
     105            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
     106        if (stack == AS_MAP_FAILED) {
     107                free(uarg);
     108                return ENOMEM;
    106109        }
    107110       
    108111        uarg->uspace_entry = (void *) FADDR(__thread_entry);
    109         uarg->uspace_stack = (void *) stack;
     112        uarg->uspace_stack = stack;
     113        uarg->uspace_stack_size = stack_size;
    110114        uarg->uspace_thread_function = function;
    111115        uarg->uspace_thread_arg = arg;
    112116        uarg->uspace_uarg = uarg;
    113117       
    114         rc = __SYSCALL4(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name,
    115             (sysarg_t) str_size(name), (sysarg_t) tid);
     118        int rc = __SYSCALL4(SYS_THREAD_CREATE, (sysarg_t) uarg,
     119            (sysarg_t) name, (sysarg_t) str_size(name), (sysarg_t) tid);
    116120       
    117         if (rc) {
     121        if (rc != EOK) {
    118122                /*
    119123                 * Failed to create a new thread.
    120                  * Free up the allocated structures.
     124                 * Free up the allocated data.
    121125                 */
     126                as_area_destroy(stack);
    122127                free(uarg);
    123                 free(stack);
    124128        }
    125 
     129       
    126130        return rc;
    127131}
  • uspace/lib/c/generic/time.c

    rba72f2b r6843a9c  
    4343#include <ddi.h>
    4444#include <libc.h>
     45#include <unistd.h>
    4546
    4647/** Pointer to kernel shared variables with time */
     
    147148                }
    148149               
    149                 void *addr = as_get_mappable_page(PAGE_SIZE);
    150                 if (addr == NULL) {
    151                         errno = ENOMEM;
    152                         return -1;
    153                 }
    154                
    155                 rc = physmem_map((void *) faddr, addr, 1,
    156                     AS_AREA_READ | AS_AREA_CACHEABLE);
     150                void *addr;
     151                rc = physmem_map((void *) faddr, 1,
     152                    AS_AREA_READ | AS_AREA_CACHEABLE, &addr);
    157153                if (rc != EOK) {
    158154                        as_area_destroy(addr);
  • uspace/lib/c/generic/vfs/vfs.c

    rba72f2b r6843a9c  
    831831}
    832832
     833int get_mtab_list(list_t *mtab_list)
     834{
     835        sysarg_t rc;
     836        aid_t req;
     837        size_t i;
     838        sysarg_t num_mounted_fs;
     839       
     840        async_exch_t *exch = vfs_exchange_begin();
     841
     842        req = async_send_0(exch, VFS_IN_MTAB_GET, NULL);
     843
     844        /* Ask VFS how many filesystems are mounted */
     845        rc = async_req_0_1(exch, VFS_IN_PING, &num_mounted_fs);
     846        if (rc != EOK)
     847                goto exit;
     848
     849        for (i = 0; i < num_mounted_fs; ++i) {
     850                mtab_ent_t *mtab_ent;
     851
     852                mtab_ent = malloc(sizeof(mtab_ent_t));
     853                if (!mtab_ent) {
     854                        rc = ENOMEM;
     855                        goto exit;
     856                }
     857
     858                memset(mtab_ent, 0, sizeof(mtab_ent_t));
     859
     860                rc = async_data_read_start(exch, (void *) mtab_ent->mp,
     861                    MAX_PATH_LEN);
     862                if (rc != EOK)
     863                        goto exit;
     864
     865                rc = async_data_read_start(exch, (void *) mtab_ent->opts,
     866                        MAX_MNTOPTS_LEN);
     867                if (rc != EOK)
     868                        goto exit;
     869
     870                rc = async_data_read_start(exch, (void *) mtab_ent->fs_name,
     871                        FS_NAME_MAXLEN);
     872                if (rc != EOK)
     873                        goto exit;
     874
     875                sysarg_t p[2];
     876
     877                rc = async_req_0_2(exch, VFS_IN_PING, &p[0], &p[1]);
     878                if (rc != EOK)
     879                        goto exit;
     880
     881                mtab_ent->instance = p[0];
     882                mtab_ent->service_id = p[1];
     883
     884                link_initialize(&mtab_ent->link);
     885                list_append(&mtab_ent->link, mtab_list);
     886        }
     887
     888exit:
     889        async_wait_for(req, &rc);
     890        vfs_exchange_end(exch);
     891        return rc;
     892}
     893
    833894/** @}
    834895 */
Note: See TracChangeset for help on using the changeset viewer.