Changeset 07b39338 in mainline for uspace/lib/c


Ignore:
Timestamp:
2011-08-20T18:21:49Z (14 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6ab014d
Parents:
0cf27ee (diff), f00af83 (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 libposix.

Location:
uspace/lib/c
Files:
35 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/abs32le/include/types.h

    r0cf27ee r07b39338  
    5353typedef int32_t intptr_t;
    5454typedef uint32_t uintptr_t;
     55typedef int32_t intptr_t;
    5556typedef uint32_t atomic_count_t;
    5657typedef int32_t atomic_signed_t;
  • uspace/lib/c/arch/amd64/include/types.h

    r0cf27ee r07b39338  
    5353typedef int64_t intptr_t;
    5454typedef uint64_t uintptr_t;
     55typedef int64_t intptr_t;
    5556typedef uint64_t atomic_count_t;
    5657typedef int64_t atomic_signed_t;
  • uspace/lib/c/arch/arm32/include/types.h

    r0cf27ee r07b39338  
    5454typedef int32_t intptr_t;
    5555typedef uint32_t uintptr_t;
     56typedef int32_t intptr_t;
    5657typedef uint32_t atomic_count_t;
    5758typedef int32_t atomic_signed_t;
  • uspace/lib/c/arch/ia32/Makefile.common

    r0cf27ee r07b39338  
    2828
    2929CLANG_ARCH = i386
     30ifeq ($(PROCESSOR),i486)
     31GCC_CFLAGS += -march=i486 -fno-omit-frame-pointer
     32else
    3033GCC_CFLAGS += -march=pentium -fno-omit-frame-pointer
     34endif
    3135
    3236ENDIANESS = LE
  • uspace/lib/c/arch/ia32/Makefile.inc

    r0cf27ee r07b39338  
    2828
    2929ARCH_SOURCES = \
    30         arch/$(UARCH)/src/entry.s \
     30        arch/$(UARCH)/src/entry.S \
    3131        arch/$(UARCH)/src/entryjmp.s \
    3232        arch/$(UARCH)/src/thread_entry.s \
  • uspace/lib/c/arch/ia32/include/types.h

    r0cf27ee r07b39338  
    5353typedef int32_t intptr_t;
    5454typedef uint32_t uintptr_t;
     55typedef int32_t intptr_t;
    5556typedef uint32_t atomic_count_t;
    5657typedef int32_t atomic_signed_t;
  • uspace/lib/c/arch/ia32/src/entry.S

    r0cf27ee r07b39338  
    4646        mov %ax, %fs
    4747        # Do not set %gs, it contains descriptor that can see TLS
    48        
     48
     49#ifndef PROCESSOR_i486 
    4950        # Detect the mechanism used for making syscalls
    5051        movl $(INTEL_CPUID_STANDARD), %eax
     
    5556        movl $__syscall_fast, (%eax)
    56570:
     58#endif
    5759        #
    5860        # Create the first stack frame.
  • uspace/lib/c/arch/ia64/include/types.h

    r0cf27ee r07b39338  
    6363typedef int64_t intptr_t;
    6464typedef uint64_t uintptr_t;
     65typedef int64_t intptr_t;
    6566typedef uint64_t atomic_count_t;
    6667typedef int64_t atomic_signed_t;
  • uspace/lib/c/arch/mips32/include/types.h

    r0cf27ee r07b39338  
    5454typedef int32_t intptr_t;
    5555typedef uint32_t uintptr_t;
     56typedef int32_t intptr_t;
    5657typedef uint32_t atomic_count_t;
    5758typedef int32_t atomic_signed_t;
  • uspace/lib/c/arch/mips64/include/types.h

    r0cf27ee r07b39338  
    5353
    5454typedef uint64_t uintptr_t;
     55typedef int64_t intptr_t;
    5556typedef uint64_t atomic_count_t;
    5657typedef int64_t atomic_signed_t;
  • uspace/lib/c/arch/ppc32/include/types.h

    r0cf27ee r07b39338  
    5353typedef int32_t intptr_t;
    5454typedef uint32_t uintptr_t;
     55typedef int32_t intptr_t;
    5556typedef uint32_t atomic_count_t;
    5657typedef int32_t atomic_signed_t;
  • uspace/lib/c/arch/sparc64/include/types.h

    r0cf27ee r07b39338  
    5353typedef int64_t intptr_t;
    5454typedef uint64_t uintptr_t;
     55typedef int64_t intptr_t;
    5556typedef uint64_t atomic_count_t;
    5657typedef int64_t atomic_signed_t;
  • uspace/lib/c/generic/async.c

    r0cf27ee r07b39338  
    112112#include <mem.h>
    113113#include <stdlib.h>
     114#include <macros.h>
    114115#include "private/async.h"
    115116
     
    138139        link_t link;
    139140       
    140         sysarg_t in_task_hash;
     141        task_id_t in_task_id;
    141142        atomic_t refcnt;
    142143        void *data;
     
    150151        link_t link;
    151152       
    152         /** Incoming client task hash. */
    153         sysarg_t in_task_hash;
     153        /** Incoming client task ID. */
     154        task_id_t in_task_id;
    154155       
    155156        /** Incoming phone hash. */
     
    203204}
    204205
    205 void *async_get_client_data(void)
    206 {
    207         assert(fibril_connection);
    208         return fibril_connection->client->data;
    209 }
    210 
    211206/** Default fibril function that gets called to handle new connection.
    212207 *
     
    289284{
    290285        assert(key);
     286        assert(keys == 2);
    291287        assert(item);
    292288       
    293289        client_t *client = hash_table_get_instance(item, client_t, link);
    294         return (key[0] == client->in_task_hash);
     290        return (key[0] == LOWER32(client->in_task_id) &&
     291            (key[1] == UPPER32(client->in_task_id)));
    295292}
    296293
     
    580577}
    581578
     579static client_t *async_client_get(task_id_t client_id, bool create)
     580{
     581        unsigned long key[2] = {
     582                LOWER32(client_id),
     583                UPPER32(client_id),
     584        };
     585        client_t *client = NULL;
     586
     587        futex_down(&async_futex);
     588        link_t *lnk = hash_table_find(&client_hash_table, key);
     589        if (lnk) {
     590                client = hash_table_get_instance(lnk, client_t, link);
     591                atomic_inc(&client->refcnt);
     592        } else if (create) {
     593                client = malloc(sizeof(client_t));
     594                if (client) {
     595                        client->in_task_id = client_id;
     596                        client->data = async_client_data_create();
     597               
     598                        atomic_set(&client->refcnt, 1);
     599                        hash_table_insert(&client_hash_table, key, &client->link);
     600                }
     601        }
     602
     603        futex_up(&async_futex);
     604        return client;
     605}
     606
     607static void async_client_put(client_t *client)
     608{
     609        bool destroy;
     610        unsigned long key[2] = {
     611                LOWER32(client->in_task_id),
     612                UPPER32(client->in_task_id)
     613        };
     614       
     615        futex_down(&async_futex);
     616       
     617        if (atomic_predec(&client->refcnt) == 0) {
     618                hash_table_remove(&client_hash_table, key, 2);
     619                destroy = true;
     620        } else
     621                destroy = false;
     622       
     623        futex_up(&async_futex);
     624       
     625        if (destroy) {
     626                if (client->data)
     627                        async_client_data_destroy(client->data);
     628               
     629                free(client);
     630        }
     631}
     632
     633void *async_get_client_data(void)
     634{
     635        assert(fibril_connection);
     636        return fibril_connection->client->data;
     637}
     638
     639void *async_get_client_data_by_id(task_id_t client_id)
     640{
     641        client_t *client = async_client_get(client_id, false);
     642        if (!client)
     643                return NULL;
     644        if (!client->data) {
     645                async_client_put(client);
     646                return NULL;
     647        }
     648
     649        return client->data;
     650}
     651
     652void async_put_client_data_by_id(task_id_t client_id)
     653{
     654        client_t *client = async_client_get(client_id, false);
     655
     656        assert(client);
     657        assert(client->data);
     658
     659        /* Drop the reference we got in async_get_client_data_by_hash(). */
     660        async_client_put(client);
     661
     662        /* Drop our own reference we got at the beginning of this function. */
     663        async_client_put(client);
     664}
     665
    582666/** Wrapper for client connection fibril.
    583667 *
     
    598682         */
    599683        fibril_connection = (connection_t *) arg;
    600        
    601         futex_down(&async_futex);
    602684       
    603685        /*
     
    606688         * hash in a new tracking structure.
    607689         */
    608        
    609         unsigned long key = fibril_connection->in_task_hash;
    610         link_t *lnk = hash_table_find(&client_hash_table, &key);
    611        
    612         client_t *client;
    613        
    614         if (lnk) {
    615                 client = hash_table_get_instance(lnk, client_t, link);
    616                 atomic_inc(&client->refcnt);
    617         } else {
    618                 client = malloc(sizeof(client_t));
    619                 if (!client) {
    620                         ipc_answer_0(fibril_connection->callid, ENOMEM);
    621                         futex_up(&async_futex);
    622                         return 0;
    623                 }
    624                
    625                 client->in_task_hash = fibril_connection->in_task_hash;
    626                 client->data = async_client_data_create();
    627                
    628                 atomic_set(&client->refcnt, 1);
    629                 hash_table_insert(&client_hash_table, &key, &client->link);
    630         }
    631        
    632         futex_up(&async_futex);
    633        
     690
     691        client_t *client = async_client_get(fibril_connection->in_task_id, true);
     692        if (!client) {
     693                ipc_answer_0(fibril_connection->callid, ENOMEM);
     694                return 0;
     695        }
     696
    634697        fibril_connection->client = client;
    635698       
     
    643706         * Remove the reference for this client task connection.
    644707         */
    645         bool destroy;
    646        
    647         futex_down(&async_futex);
    648        
    649         if (atomic_predec(&client->refcnt) == 0) {
    650                 hash_table_remove(&client_hash_table, &key, 1);
    651                 destroy = true;
    652         } else
    653                 destroy = false;
    654        
    655         futex_up(&async_futex);
    656        
    657         if (destroy) {
    658                 if (client->data)
    659                         async_client_data_destroy(client->data);
    660                
    661                 free(client);
    662         }
     708        async_client_put(client);
    663709       
    664710        /*
     
    666712         */
    667713        futex_down(&async_futex);
    668         key = fibril_connection->in_phone_hash;
     714        unsigned long key = fibril_connection->in_phone_hash;
    669715        hash_table_remove(&conn_hash_table, &key, 1);
    670716        futex_up(&async_futex);
     
    700746 * particular fibrils.
    701747 *
    702  * @param in_task_hash  Identification of the incoming connection.
     748 * @param in_task_id    Identification of the incoming connection.
    703749 * @param in_phone_hash Identification of the incoming connection.
    704750 * @param callid        Hash of the opening IPC_M_CONNECT_ME_TO call.
     
    714760 *
    715761 */
    716 fid_t async_new_connection(sysarg_t in_task_hash, sysarg_t in_phone_hash,
     762fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash,
    717763    ipc_callid_t callid, ipc_call_t *call,
    718764    async_client_conn_t cfibril, void *carg)
     
    726772        }
    727773       
    728         conn->in_task_hash = in_task_hash;
     774        conn->in_task_id = in_task_id;
    729775        conn->in_phone_hash = in_phone_hash;
    730776        list_initialize(&conn->msg_queue);
     
    785831        case IPC_M_CONNECT_ME_TO:
    786832                /* Open new connection with fibril, etc. */
    787                 async_new_connection(call->in_task_hash, IPC_GET_ARG5(*call),
     833                async_new_connection(call->in_task_id, IPC_GET_ARG5(*call),
    788834                    callid, call, client_connection, NULL);
    789835                return;
     
    933979{
    934980        if (!hash_table_create(&client_hash_table, CLIENT_HASH_TABLE_BUCKETS,
    935             1, &client_hash_table_ops))
     981            2, &client_hash_table_ops))
    936982                abort();
    937983       
     
    14261472                return ENOENT;
    14271473       
    1428         sysarg_t task_hash;
     1474        task_id_t task_id;
     1475        sysarg_t task_id_lo;
     1476        sysarg_t task_id_hi;
    14291477        sysarg_t phone_hash;
    14301478        int rc = async_req_3_5(exch, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3,
    1431             NULL, NULL, NULL, &task_hash, &phone_hash);
     1479            NULL, NULL, &task_id_lo, &task_id_hi, &phone_hash);
    14321480        if (rc != EOK)
    14331481                return rc;
     1482
     1483        task_id = (task_id_t) MERGE_LOUP32(task_id_lo, task_id_hi);
    14341484       
    14351485        if (client_receiver != NULL)
    1436                 async_new_connection(task_hash, phone_hash, 0, NULL,
     1486                async_new_connection(task_id, phone_hash, 0, NULL,
    14371487                    client_receiver, carg);
    14381488       
     
    24292479}
    24302480
     2481int async_state_change_start(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2,
     2482    sysarg_t arg3, async_exch_t *other_exch)
     2483{
     2484        return async_req_5_0(exch, IPC_M_STATE_CHANGE_AUTHORIZE,
     2485            arg1, arg2, arg3, 0, other_exch->phone);
     2486}
     2487
     2488bool async_state_change_receive(ipc_callid_t *callid, sysarg_t *arg1,
     2489    sysarg_t *arg2, sysarg_t *arg3)
     2490{
     2491        assert(callid);
     2492
     2493        ipc_call_t call;
     2494        *callid = async_get_call(&call);
     2495
     2496        if (IPC_GET_IMETHOD(call) != IPC_M_STATE_CHANGE_AUTHORIZE)
     2497                return false;
     2498       
     2499        if (arg1)
     2500                *arg1 = IPC_GET_ARG1(call);
     2501        if (arg2)
     2502                *arg2 = IPC_GET_ARG2(call);
     2503        if (arg3)
     2504                *arg3 = IPC_GET_ARG3(call);
     2505
     2506        return true;
     2507}
     2508
     2509int async_state_change_finalize(ipc_callid_t callid, async_exch_t *other_exch)
     2510{
     2511        return ipc_answer_1(callid, EOK, other_exch->phone);
     2512}
     2513
    24312514/** @}
    24322515 */
  • uspace/lib/c/generic/devman.c

    r0cf27ee r07b39338  
    11/*
    22 * Copyright (c) 2007 Josef Cejka
    3  * Copyright (c) 2009 Jiri Svoboda
     3 * Copyright (c) 2011 Jiri Svoboda
    44 * Copyright (c) 2010 Lenka Trochtova
    55 * All rights reserved.
     
    195195       
    196196        exch = devman_exchange_begin(DEVMAN_DRIVER);
    197         async_connect_to_me(exch, 0, 0, 0, NULL, NULL);
     197        async_connect_to_me(exch, 0, 0, 0, conn, NULL);
    198198        devman_exchange_end(exch);
    199199       
     
    271271}
    272272
    273 int devman_add_device_to_class(devman_handle_t devman_handle,
    274     const char *class_name)
     273int devman_add_device_to_category(devman_handle_t devman_handle,
     274    const char *cat_name)
    275275{
    276276        async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_DRIVER);
    277277       
    278278        ipc_call_t answer;
    279         aid_t req = async_send_1(exch, DEVMAN_ADD_DEVICE_TO_CLASS,
     279        aid_t req = async_send_1(exch, DEVMAN_ADD_DEVICE_TO_CATEGORY,
    280280            devman_handle, &answer);
    281         sysarg_t retval = async_data_write_start(exch, class_name,
    282             str_size(class_name));
     281        sysarg_t retval = async_data_write_start(exch, cat_name,
     282            str_size(cat_name));
    283283       
    284284        devman_exchange_end(exch);
     
    308308}
    309309
     310/** Remove function from device.
     311 *
     312 * Request devman to remove function owned by this driver task.
     313 * @param funh      Devman handle of the function
     314 *
     315 * @return EOK on success or negative error code.
     316 */
     317int devman_remove_function(devman_handle_t funh)
     318{
     319        async_exch_t *exch;
     320        sysarg_t retval;
     321       
     322        exch = devman_exchange_begin_blocking(DEVMAN_DRIVER);
     323        retval = async_req_1_0(exch, DEVMAN_REMOVE_FUNCTION, (sysarg_t) funh);
     324        devman_exchange_end(exch);
     325       
     326        return (int) retval;
     327}
     328
    310329async_sess_t *devman_parent_device_connect(exch_mgmt_t mgmt,
    311330    devman_handle_t handle, unsigned int flags)
     
    323342}
    324343
    325 int devman_device_get_handle(const char *pathname, devman_handle_t *handle,
     344int devman_fun_get_handle(const char *pathname, devman_handle_t *handle,
    326345    unsigned int flags)
    327346{
     
    333352                exch = devman_exchange_begin(DEVMAN_CLIENT);
    334353                if (exch == NULL)
    335                         return errno;
     354                        return ENOMEM;
    336355        }
    337356       
     
    364383}
    365384
    366 int devman_device_get_handle_by_class(const char *classname,
    367     const char *devname, devman_handle_t *handle, unsigned int flags)
     385static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, char *buf,
     386    size_t buf_size)
    368387{
    369388        async_exch_t *exch;
    370        
    371         if (flags & IPC_FLAG_BLOCKING)
    372                 exch = devman_exchange_begin_blocking(DEVMAN_CLIENT);
    373         else {
    374                 exch = devman_exchange_begin(DEVMAN_CLIENT);
    375                 if (exch == NULL)
    376                         return errno;
    377         }
     389        ipc_call_t dreply;
     390        size_t act_size;
     391        sysarg_t dretval;
     392       
     393        exch = devman_exchange_begin_blocking(LOC_PORT_CONSUMER);
    378394       
    379395        ipc_call_t answer;
    380         aid_t req = async_send_1(exch, DEVMAN_DEVICE_GET_HANDLE_BY_CLASS,
    381             flags, &answer);
    382         sysarg_t retval = async_data_write_start(exch, classname,
    383             str_size(classname));
     396        aid_t req = async_send_1(exch, method, arg1, &answer);
     397        aid_t dreq = async_data_read(exch, buf, buf_size - 1, &dreply);
     398        async_wait_for(dreq, &dretval);
     399       
     400        devman_exchange_end(exch);
     401       
     402        if (dretval != EOK) {
     403                async_wait_for(req, NULL);
     404                return dretval;
     405        }
     406       
     407        sysarg_t retval;
     408        async_wait_for(req, &retval);
     409       
     410        if (retval != EOK)
     411                return retval;
     412       
     413        act_size = IPC_GET_ARG2(dreply);
     414        assert(act_size <= buf_size - 1);
     415        buf[act_size] = '\0';
     416       
     417        return EOK;
     418}
     419
     420int devman_fun_get_path(devman_handle_t handle, char *buf, size_t buf_size)
     421{
     422        return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, buf,
     423            buf_size);
     424}
     425
     426int devman_fun_get_name(devman_handle_t handle, char *buf, size_t buf_size)
     427{
     428        return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf,
     429            buf_size);
     430}
     431
     432static int devman_get_handles_once(sysarg_t method, sysarg_t arg1,
     433    devman_handle_t *handle_buf, size_t buf_size, size_t *act_size)
     434{
     435        async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_CLIENT);
     436
     437        ipc_call_t answer;
     438        aid_t req = async_send_1(exch, method, arg1, &answer);
     439        int rc = async_data_read_start(exch, handle_buf, buf_size);
     440       
     441        devman_exchange_end(exch);
     442       
     443        if (rc != EOK) {
     444                async_wait_for(req, NULL);
     445                return rc;
     446        }
     447       
     448        sysarg_t retval;
     449        async_wait_for(req, &retval);
    384450       
    385451        if (retval != EOK) {
    386                 devman_exchange_end(exch);
    387                 async_wait_for(req, NULL);
    388                 return retval;
    389         }
    390        
    391         retval = async_data_write_start(exch, devname,
    392             str_size(devname));
    393        
    394         devman_exchange_end(exch);
    395        
    396         if (retval != EOK) {
    397                 async_wait_for(req, NULL);
    398                 return retval;
    399         }
    400        
    401         async_wait_for(req, &retval);
    402        
    403         if (retval != EOK) {
    404                 if (handle != NULL)
    405                         *handle = (devman_handle_t) -1;
    406                
    407                 return retval;
    408         }
    409        
    410         if (handle != NULL)
    411                 *handle = (devman_handle_t) IPC_GET_ARG1(answer);
    412        
    413         return retval;
    414 }
    415 
    416 int devman_get_device_path(devman_handle_t handle, char *path, size_t path_size)
     452                return retval;
     453        }
     454       
     455        *act_size = IPC_GET_ARG1(answer);
     456        return EOK;
     457}
     458
     459/** Get list of handles.
     460 *
     461 * Returns an allocated array of handles.
     462 *
     463 * @param method        IPC method
     464 * @param arg1          IPC argument 1
     465 * @param data          Place to store pointer to array of handles
     466 * @param count         Place to store number of handles
     467 * @return              EOK on success or negative error code
     468 */
     469static int devman_get_handles_internal(sysarg_t method, sysarg_t arg1,
     470    devman_handle_t **data, size_t *count)
     471{
     472        devman_handle_t *handles;
     473        size_t act_size;
     474        size_t alloc_size;
     475        int rc;
     476
     477        *data = NULL;
     478        act_size = 0;   /* silence warning */
     479
     480        rc = devman_get_handles_once(method, arg1, NULL, 0,
     481            &act_size);
     482        if (rc != EOK)
     483                return rc;
     484
     485        alloc_size = act_size;
     486        handles = malloc(alloc_size);
     487        if (handles == NULL)
     488                return ENOMEM;
     489
     490        while (true) {
     491                rc = devman_get_handles_once(method, arg1, handles, alloc_size,
     492                    &act_size);
     493                if (rc != EOK)
     494                        return rc;
     495
     496                if (act_size <= alloc_size)
     497                        break;
     498
     499                alloc_size *= 2;
     500                free(handles);
     501
     502                handles = malloc(alloc_size);
     503                if (handles == NULL)
     504                        return ENOMEM;
     505        }
     506
     507        *count = act_size / sizeof(devman_handle_t);
     508        *data = handles;
     509        return EOK;
     510}
     511
     512int devman_fun_get_child(devman_handle_t funh, devman_handle_t *devh)
    417513{
    418514        async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
    419515        if (exch == NULL)
    420                 return errno;
    421        
    422         ipc_call_t answer;
    423         aid_t req = async_send_1(exch, DEVMAN_DEVICE_GET_DEVICE_PATH,
    424             handle, &answer);
    425        
    426         ipc_call_t data_request_call;
    427         aid_t data_request = async_data_read(exch, path, path_size,
    428             &data_request_call);
    429        
    430         devman_exchange_end(exch);
    431        
    432         if (data_request == 0) {
    433                 async_wait_for(req, NULL);
    434516                return ENOMEM;
    435         }
    436        
    437         sysarg_t data_request_rc;
    438         async_wait_for(data_request, &data_request_rc);
    439        
    440         sysarg_t opening_request_rc;
    441         async_wait_for(req, &opening_request_rc);
    442        
    443         if (data_request_rc != EOK) {
    444                 /* Prefer the return code of the opening request. */
    445                 if (opening_request_rc != EOK)
    446                         return (int) opening_request_rc;
    447                 else
    448                         return (int) data_request_rc;
    449         }
    450        
    451         if (opening_request_rc != EOK)
    452                 return (int) opening_request_rc;
    453        
    454         /* To be on the safe-side. */
    455         path[path_size - 1] = 0;
    456         size_t transferred_size = IPC_GET_ARG2(data_request_call);
    457         if (transferred_size >= path_size)
    458                 return ELIMIT;
    459        
    460         /* Terminate the string (trailing 0 not send over IPC). */
    461         path[transferred_size] = 0;
    462         return EOK;
     517       
     518        sysarg_t retval = async_req_1_1(exch, DEVMAN_FUN_GET_CHILD,
     519            funh, devh);
     520       
     521        devman_exchange_end(exch);
     522        return (int) retval;
     523}
     524
     525int devman_dev_get_functions(devman_handle_t devh, devman_handle_t **funcs,
     526    size_t *count)
     527{
     528        return devman_get_handles_internal(DEVMAN_DEV_GET_FUNCTIONS,
     529            devh, funcs, count);
     530}
     531
     532int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle)
     533{
     534        async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
     535        if (exch == NULL)
     536                return ENOMEM;
     537       
     538        sysarg_t retval = async_req_1_1(exch, DEVMAN_FUN_SID_TO_HANDLE,
     539            sid, handle);
     540       
     541        devman_exchange_end(exch);
     542        return (int) retval;
    463543}
    464544
  • uspace/lib/c/generic/event.c

    r0cf27ee r07b39338  
    5454}
    5555
     56int event_task_subscribe(event_task_type_t evno, sysarg_t imethod)
     57{
     58        return __SYSCALL2(SYS_EVENT_SUBSCRIBE, (sysarg_t) evno,
     59            (sysarg_t) imethod);
     60}
     61
    5662/** Unmask event notifications.
    5763 *
     
    6672}
    6773
     74int event_task_unmask(event_task_type_t evno)
     75{
     76        return __SYSCALL1(SYS_EVENT_UNMASK, (sysarg_t) evno);
     77}
     78
    6879/** @}
    6980 */
  • uspace/lib/c/generic/io/io.c

    r0cf27ee r07b39338  
    101101static LIST_INITIALIZE(files);
    102102
    103 void __stdio_init(int filc, fdi_node_t *filv[])
     103void __stdio_init(int filc)
    104104{
    105105        if (filc > 0) {
    106                 stdin = fopen_node(filv[0], "r");
     106                stdin = fdopen(0, "r");
    107107        } else {
    108108                stdin = &stdin_null;
     
    111111       
    112112        if (filc > 1) {
    113                 stdout = fopen_node(filv[1], "w");
     113                stdout = fdopen(1, "w");
    114114        } else {
    115115                stdout = &stdout_klog;
     
    118118       
    119119        if (filc > 2) {
    120                 stderr = fopen_node(filv[2], "w");
     120                stderr = fdopen(2, "w");
    121121        } else {
    122122                stderr = &stderr_klog;
     
    285285}
    286286
    287 FILE *fopen_node(fdi_node_t *node, const char *mode)
    288 {
    289         int flags;
    290         if (!parse_mode(mode, &flags))
    291                 return NULL;
    292        
    293         /* Open file. */
    294         FILE *stream = malloc(sizeof(FILE));
    295         if (stream == NULL) {
    296                 errno = ENOMEM;
    297                 return NULL;
    298         }
    299        
    300         stream->fd = open_node(node, flags);
    301         if (stream->fd < 0) {
    302                 /* errno was set by open_node() */
    303                 free(stream);
    304                 return NULL;
    305         }
    306        
    307         stream->error = false;
    308         stream->eof = false;
    309         stream->klog = false;
    310         stream->sess = NULL;
    311         stream->need_sync = false;
    312         _setvbuf(stream);
    313        
    314         list_append(&stream->link, &files);
    315        
    316         return stream;
    317 }
    318 
    319287int fclose(FILE *stream)
    320288{
     
    780748}
    781749
    782 int fnode(FILE *stream, fdi_node_t *node)
    783 {
    784         if (stream->fd >= 0)
    785                 return fd_node(stream->fd, node);
     750int fhandle(FILE *stream, int *handle)
     751{
     752        if (stream->fd >= 0) {
     753                *handle = stream->fd;
     754                return EOK;
     755        }
    786756       
    787757        return ENOENT;
  • uspace/lib/c/generic/io/printf_core.c

    r0cf27ee r07b39338  
    206206        }
    207207       
    208         return (int) (counter + 1);
     208        return (int) (counter);
    209209}
    210210
     
    244244        }
    245245       
    246         return (int) (counter + 1);
     246        return (int) (counter);
    247247}
    248248
  • uspace/lib/c/generic/libc.c

    r0cf27ee r07b39338  
    9191                argc = 0;
    9292                argv = NULL;
    93                 __stdio_init(0, NULL);
     93                __stdio_init(0);
    9494        } else {
    9595                argc = __pcb->argc;
    9696                argv = __pcb->argv;
    97                 __stdio_init(__pcb->filc, __pcb->filv);
     97                __stdio_init(__pcb->filc);
    9898                (void) chdir(__pcb->cwd);
    9999        }
  • uspace/lib/c/generic/loader.c

    r0cf27ee r07b39338  
    256256 *
    257257 */
    258 int loader_set_files(loader_t *ldr, fdi_node_t *const files[])
    259 {
    260         /*
    261          * Serialize the arguments into a single array. First
    262          * compute size of the buffer needed.
    263          */
    264         fdi_node_t *const *ap = files;
    265         size_t count = 0;
    266         while (*ap != NULL) {
    267                 count++;
    268                 ap++;
    269         }
    270        
    271         fdi_node_t *files_buf;
    272         files_buf = (fdi_node_t *) malloc(count * sizeof(fdi_node_t));
    273         if (files_buf == NULL)
    274                 return ENOMEM;
    275        
    276         /* Fill the buffer */
    277         size_t i;
    278         for (i = 0; i < count; i++)
    279                 files_buf[i] = *files[i];
    280        
     258int loader_set_files(loader_t *ldr, int * const files[])
     259{
    281260        /* Send serialized files to the loader */
    282261        async_exch_t *exch = async_exchange_begin(ldr->sess);
    283        
    284         ipc_call_t answer;
    285         aid_t req = async_send_0(exch, LOADER_SET_FILES, &answer);
    286         sysarg_t rc = async_data_write_start(exch, (void *) files_buf,
    287             count * sizeof(fdi_node_t));
    288        
    289         async_exchange_end(exch);
    290         free(files_buf);
    291        
     262        async_exch_t *vfs_exch = vfs_exchange_begin();
     263       
     264        int i;
     265        for (i = 0; files[i]; i++);
     266
     267        ipc_call_t answer;
     268        aid_t req = async_send_1(exch, LOADER_SET_FILES, i, &answer);
     269
     270        sysarg_t rc = EOK;
     271       
     272        for (i = 0; files[i]; i++) {
     273                rc = async_state_change_start(exch, VFS_PASS_HANDLE, *files[i],
     274                    0, vfs_exch);
     275                if (rc != EOK)
     276                        break;
     277        }
     278       
     279        vfs_exchange_end(vfs_exch);
     280        async_exchange_end(exch);
     281
    292282        if (rc != EOK) {
    293283                async_wait_for(req, NULL);
  • uspace/lib/c/generic/loc.c

    r0cf27ee r07b39338  
    4545static FIBRIL_MUTEX_INITIALIZE(loc_consumer_mutex);
    4646
     47static FIBRIL_MUTEX_INITIALIZE(loc_callback_mutex);
     48static bool loc_callback_created = false;
     49
    4750static async_sess_t *loc_supp_block_sess = NULL;
    4851static async_sess_t *loc_cons_block_sess = NULL;
     
    5154static async_sess_t *loc_consumer_sess = NULL;
    5255
     56static loc_cat_change_cb_t cat_change_cb = NULL;
     57
     58static void loc_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     59{
     60        loc_cat_change_cb_t cb_fun;
     61       
     62        while (true) {
     63                ipc_call_t call;
     64                ipc_callid_t callid = async_get_call(&call);
     65               
     66                if (!IPC_GET_IMETHOD(call)) {
     67                        /* TODO: Handle hangup */
     68                        return;
     69                }
     70               
     71                int retval;
     72               
     73                switch (IPC_GET_IMETHOD(call)) {
     74                case LOC_EVENT_CAT_CHANGE:
     75                        fibril_mutex_lock(&loc_callback_mutex);
     76                        cb_fun = cat_change_cb;
     77                        if (cb_fun != NULL) {
     78                                (*cb_fun)();
     79                        }
     80                        fibril_mutex_unlock(&loc_callback_mutex);
     81                        retval = 0;
     82                        break;
     83                default:
     84                        retval = ENOTSUP;
     85                }
     86               
     87                async_answer_0(callid, retval);
     88        }
     89}
     90
     91
    5392static void clone_session(fibril_mutex_t *mtx, async_sess_t *src,
    5493    async_sess_t **dst)
     
    6099       
    61100        fibril_mutex_unlock(mtx);
     101}
     102
     103static int loc_callback_create(void)
     104{
     105        async_exch_t *exch;
     106        sysarg_t retval;
     107        int rc = EOK;
     108
     109        fibril_mutex_lock(&loc_callback_mutex);
     110       
     111        if (!loc_callback_created) {
     112                exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
     113               
     114                ipc_call_t answer;
     115                aid_t req = async_send_0(exch, LOC_CALLBACK_CREATE, &answer);
     116                async_connect_to_me(exch, 0, 0, 0, loc_cb_conn, NULL);
     117                loc_exchange_end(exch);
     118               
     119                async_wait_for(req, &retval);
     120                if (rc != EOK)
     121                        goto done;
     122               
     123                if (retval != EOK) {
     124                        rc = retval;
     125                        goto done;
     126                }
     127               
     128                loc_callback_created = true;
     129        }
     130       
     131        rc = EOK;
     132done:
     133        fibril_mutex_unlock(&loc_callback_mutex);
     134        return rc;
    62135}
    63136
     
    194267}
    195268
    196 /** Register new device.
    197  *
    198  * The @p interface is used when forwarding connection to the driver.
     269/** Register new service.
     270 *
     271 * The @p interface is used when forwarding connection to the server.
    199272 * If not 0, the first argument is the interface and the second argument
    200273 * is the service ID.
     
    203276 * the handle (to ensure backward compatibility).
    204277 *
    205  * @param      fqdn      Fully qualified device name.
    206  * @param[out] handle    Handle to the created instance of device.
    207  * @param      interface Interface when forwarding.
    208  *
    209  */
    210 int loc_service_register_with_iface(const char *fqdn,
    211     service_id_t *handle, sysarg_t interface)
     278 * @param      fqsn      Fully qualified service name
     279 * @param[out] sid       Service ID of new service
     280 * @param      interface Interface when forwarding
     281 *
     282 */
     283int loc_service_register_with_iface(const char *fqsn,
     284    service_id_t *sid, sysarg_t interface)
    212285{
    213286        async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_SUPPLIER);
     
    216289        aid_t req = async_send_2(exch, LOC_SERVICE_REGISTER, interface, 0,
    217290            &answer);
    218         sysarg_t retval = async_data_write_start(exch, fqdn, str_size(fqdn));
     291        sysarg_t retval = async_data_write_start(exch, fqsn, str_size(fqsn));
    219292       
    220293        loc_exchange_end(exch);
     
    228301       
    229302        if (retval != EOK) {
    230                 if (handle != NULL)
    231                         *handle = -1;
    232                
    233                 return retval;
    234         }
    235        
    236         if (handle != NULL)
    237                 *handle = (service_id_t) IPC_GET_ARG1(answer);
     303                if (sid != NULL)
     304                        *sid = -1;
     305               
     306                return retval;
     307        }
     308       
     309        if (sid != NULL)
     310                *sid = (service_id_t) IPC_GET_ARG1(answer);
    238311       
    239312        return retval;
    240313}
    241314
    242 /** Register new device.
    243  *
    244  * @param fqdn   Fully qualified device name.
    245  * @param handle Output: Handle to the created instance of device.
    246  *
    247  */
    248 int loc_service_register(const char *fqdn, service_id_t *handle)
    249 {
    250         return loc_service_register_with_iface(fqdn, handle, 0);
     315/** Register new service.
     316 *
     317 * @param fqsn Fully qualified service name
     318 * @param sid  Output: ID of new service
     319 *
     320 */
     321int loc_service_register(const char *fqdn, service_id_t *sid)
     322{
     323        return loc_service_register_with_iface(fqdn, sid, 0);
     324}
     325
     326/** Unregister service.
     327 *
     328 * @param sid   Service ID
     329 */
     330int loc_service_unregister(service_id_t sid)
     331{
     332        async_exch_t *exch;
     333        sysarg_t retval;
     334       
     335        exch = loc_exchange_begin_blocking(LOC_PORT_SUPPLIER);
     336        retval = async_req_1_0(exch, LOC_SERVICE_UNREGISTER, sid);
     337        loc_exchange_end(exch);
     338       
     339        return (int)retval;
    251340}
    252341
     
    291380}
    292381
    293 /** Get service name.
    294  *
    295  * Provided ID of a service, return its name.
    296  *
    297  * @param svc_id        Service ID
     382/** Get object name.
     383 *
     384 * Provided ID of an object, return its name.
     385 *
     386 * @param method        IPC method
     387 * @param id            Object ID
    298388 * @param name          Place to store pointer to new string. Caller should
    299389 *                      free it using free().
    300390 * @return              EOK on success or negative error code
    301391 */
    302 int loc_service_get_name(service_id_t svc_id, char **name)
     392static int loc_get_name_internal(sysarg_t method, sysarg_t id, char **name)
    303393{
    304394        async_exch_t *exch;
     
    312402       
    313403        ipc_call_t answer;
    314         aid_t req = async_send_1(exch, LOC_SERVICE_GET_NAME, svc_id, &answer);
     404        aid_t req = async_send_1(exch, method, id, &answer);
    315405        aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN,
    316406            &dreply);
     
    341431}
    342432
     433/** Get category name.
     434 *
     435 * Provided ID of a service, return its name.
     436 *
     437 * @param cat_id        Category ID
     438 * @param name          Place to store pointer to new string. Caller should
     439 *                      free it using free().
     440 * @return              EOK on success or negative error code
     441 */
     442int loc_category_get_name(category_id_t cat_id, char **name)
     443{
     444        return loc_get_name_internal(LOC_CATEGORY_GET_NAME, cat_id, name);
     445}
     446
     447/** Get service name.
     448 *
     449 * Provided ID of a service, return its name.
     450 *
     451 * @param svc_id        Service ID
     452 * @param name          Place to store pointer to new string. Caller should
     453 *                      free it using free().
     454 * @return              EOK on success or negative error code
     455 */
     456int loc_service_get_name(service_id_t svc_id, char **name)
     457{
     458        return loc_get_name_internal(LOC_SERVICE_GET_NAME, svc_id, name);
     459}
    343460
    344461int loc_namespace_get_id(const char *name, service_id_t *handle,
     
    749866            data, count);
    750867}
     868
     869int loc_register_cat_change_cb(loc_cat_change_cb_t cb_fun)
     870{
     871        if (loc_callback_create() != EOK)
     872                return EIO;
     873
     874        cat_change_cb = cb_fun;
     875        return EOK;
     876}
  • uspace/lib/c/generic/private/async.h

    r0cf27ee r07b39338  
    3636#define LIBC_PRIVATE_ASYNC_H_
    3737
     38#include <ipc/common.h>
    3839#include <adt/list.h>
    3940#include <fibril.h>
  • uspace/lib/c/generic/private/io.h

    r0cf27ee r07b39338  
    3636#define LIBC_PRIVATE_IO_H_
    3737
    38 #include <vfs/vfs.h>
    39 
    40 extern void __stdio_init(int filc, fdi_node_t *filv[]);
     38extern void __stdio_init(int);
    4139extern void __stdio_done(void);
    4240
  • uspace/lib/c/generic/task.c

    r0cf27ee r07b39338  
    4646#include <libc.h>
    4747#include "private/ns.h"
     48#include <vfs/vfs.h>
    4849
    4950task_id_t task_get_id(void)
     
    102103{
    103104        /* Send default files */
    104         fdi_node_t *files[4];
    105         fdi_node_t stdin_node;
    106         fdi_node_t stdout_node;
    107         fdi_node_t stderr_node;
    108        
    109         if ((stdin != NULL) && (fnode(stdin, &stdin_node) == EOK))
    110                 files[0] = &stdin_node;
     105        int *files[4];
     106        int fd_stdin;
     107        int fd_stdout;
     108        int fd_stderr;
     109       
     110        if ((stdin != NULL) && (fhandle(stdin, &fd_stdin) == EOK))
     111                files[0] = &fd_stdin;
    111112        else
    112113                files[0] = NULL;
    113114       
    114         if ((stdout != NULL) && (fnode(stdout, &stdout_node) == EOK))
    115                 files[1] = &stdout_node;
     115        if ((stdout != NULL) && (fhandle(stdout, &fd_stdout) == EOK))
     116                files[1] = &fd_stdout;
    116117        else
    117118                files[1] = NULL;
    118119       
    119         if ((stderr != NULL) && (fnode(stderr, &stderr_node) == EOK))
    120                 files[2] = &stderr_node;
     120        if ((stderr != NULL) && (fhandle(stderr, &fd_stderr) == EOK))
     121                files[2] = &fd_stderr;
    121122        else
    122123                files[2] = NULL;
     
    142143 */
    143144int task_spawnvf(task_id_t *id, const char *path, const char *const args[],
    144     fdi_node_t *const files[])
     145    int *const files[])
    145146{
    146147        /* Connect to a program loader. */
  • uspace/lib/c/generic/vfs/vfs.c

    r0cf27ee r07b39338  
    6969 *
    7070 */
    71 static async_exch_t *vfs_exchange_begin(void)
     71async_exch_t *vfs_exchange_begin(void)
    7272{
    7373        fibril_mutex_lock(&vfs_mutex);
     
    8787 *
    8888 */
    89 static void vfs_exchange_end(async_exch_t *exch)
     89void vfs_exchange_end(async_exch_t *exch)
    9090{
    9191        async_exchange_end(exch);
     
    329329}
    330330
    331 int open_node(fdi_node_t *node, int oflag)
    332 {
    333         async_exch_t *exch = vfs_exchange_begin();
    334        
    335         ipc_call_t answer;
    336         aid_t req = async_send_4(exch, VFS_IN_OPEN_NODE, node->fs_handle,
    337             node->service_id, node->index, oflag, &answer);
    338        
    339         vfs_exchange_end(exch);
    340 
    341         sysarg_t rc;
    342         async_wait_for(req, &rc);
    343        
    344         if (rc != EOK)
    345                 return (int) rc;
    346        
    347         return (int) IPC_GET_ARG1(answer);
    348 }
    349 
    350331int close(int fildes)
    351332{
     
    819800}
    820801
    821 int fd_node(int fildes, fdi_node_t *node)
    822 {
    823         struct stat stat;
    824         int rc = fstat(fildes, &stat);
    825        
    826         if (rc == EOK) {
    827                 node->fs_handle = stat.fs_handle;
    828                 node->service_id = stat.service_id;
    829                 node->index = stat.index;
    830         }
    831        
    832         return rc;
    833 }
    834 
    835802int dup2(int oldfd, int newfd)
    836803{
     
    848815}
    849816
     817int fd_wait(void)
     818{
     819        async_exch_t *exch = vfs_exchange_begin();
     820       
     821        sysarg_t ret;
     822        sysarg_t rc = async_req_0_1(exch, VFS_IN_WAIT_HANDLE, &ret);
     823       
     824        vfs_exchange_end(exch);
     825       
     826        if (rc == EOK)
     827                return (int) ret;
     828       
     829        return (int) rc;
     830}
     831
    850832/** @}
    851833 */
  • uspace/lib/c/include/async.h

    r0cf27ee r07b39338  
    176176extern int async_wait_timeout(aid_t, sysarg_t *, suseconds_t);
    177177
    178 extern fid_t async_new_connection(sysarg_t, sysarg_t, ipc_callid_t,
     178extern fid_t async_new_connection(task_id_t, sysarg_t, ipc_callid_t,
    179179    ipc_call_t *, async_client_conn_t, void *);
    180180
     
    186186extern void async_set_client_data_destructor(async_client_data_dtor_t);
    187187extern void *async_get_client_data(void);
     188extern void *async_get_client_data_by_id(task_id_t);
     189extern void async_put_client_data_by_id(task_id_t);
    188190
    189191extern void async_set_client_connection(async_client_conn_t);
     
    477479extern async_sess_t *async_callback_receive_start(exch_mgmt_t, ipc_call_t *);
    478480
     481extern int async_state_change_start(async_exch_t *, sysarg_t, sysarg_t,
     482    sysarg_t, async_exch_t *);
     483extern bool async_state_change_receive(ipc_callid_t *, sysarg_t *, sysarg_t *,
     484    sysarg_t *);
     485extern int async_state_change_finalize(ipc_callid_t, async_exch_t *);
     486
    479487#endif
    480488
  • uspace/lib/c/include/devman.h

    r0cf27ee r07b39338  
    3838
    3939#include <ipc/devman.h>
     40#include <ipc/loc.h>
    4041#include <async.h>
    4142#include <bool.h>
     
    4849extern int devman_add_function(const char *, fun_type_t, match_id_list_t *,
    4950    devman_handle_t, devman_handle_t *);
     51extern int devman_remove_function(devman_handle_t);
    5052
    5153extern async_sess_t *devman_device_connect(exch_mgmt_t, devman_handle_t,
     
    5456    unsigned int);
    5557
    56 extern int devman_device_get_handle(const char *, devman_handle_t *,
     58extern int devman_fun_get_handle(const char *, devman_handle_t *,
    5759    unsigned int);
    58 extern int devman_device_get_handle_by_class(const char *, const char *,
    59     devman_handle_t *, unsigned int);
    60 extern int devman_get_device_path(devman_handle_t, char *, size_t);
     60extern int devman_fun_get_child(devman_handle_t, devman_handle_t *);
     61extern int devman_dev_get_functions(devman_handle_t, devman_handle_t **,
     62    size_t *);
     63extern int devman_fun_get_name(devman_handle_t, char *, size_t);
     64extern int devman_fun_get_path(devman_handle_t, char *, size_t);
    6165
    62 extern int devman_add_device_to_class(devman_handle_t, const char *);
     66extern int devman_add_device_to_category(devman_handle_t, const char *);
     67extern int devman_fun_sid_to_handle(service_id_t, devman_handle_t *);
    6368
    6469#endif
  • uspace/lib/c/include/event.h

    r0cf27ee r07b39338  
    3737
    3838#include <abi/ipc/event.h>
     39#include <libarch/types.h>
    3940
    4041extern int event_subscribe(event_type_t, sysarg_t);
     42extern int event_task_subscribe(event_task_type_t, sysarg_t);
    4143extern int event_unmask(event_type_t);
     44extern int event_task_unmask(event_task_type_t);
    4245
    4346#endif
  • uspace/lib/c/include/ipc/common.h

    r0cf27ee r07b39338  
    3939#include <abi/ipc/ipc.h>
    4040#include <atomic.h>
     41#include <task.h>
    4142
    4243#define IPC_FLAG_BLOCKING  0x01
     
    4445typedef struct {
    4546        sysarg_t args[IPC_CALL_LEN];
    46         sysarg_t in_task_hash;
     47        task_id_t in_task_id;
    4748        sysarg_t in_phone_hash;
    4849} ipc_call_t;
  • uspace/lib/c/include/ipc/devman.h

    r0cf27ee r07b39338  
    138138        DEVMAN_ADD_FUNCTION,
    139139        DEVMAN_ADD_MATCH_ID,
    140         DEVMAN_ADD_DEVICE_TO_CLASS
    141 
     140        DEVMAN_ADD_DEVICE_TO_CATEGORY,
     141        DEVMAN_REMOVE_FUNCTION
    142142} driver_to_devman_t;
    143143
     
    149149typedef enum {
    150150        DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD,
    151         DEVMAN_DEVICE_GET_HANDLE_BY_CLASS,
    152         DEVMAN_DEVICE_GET_DEVICE_PATH
     151        DEVMAN_DEV_GET_FUNCTIONS,
     152        DEVMAN_FUN_GET_CHILD,
     153        DEVMAN_FUN_GET_NAME,
     154        DEVMAN_FUN_GET_PATH,
     155        DEVMAN_FUN_SID_TO_HANDLE
    153156} client_to_devman_t;
    154157
  • uspace/lib/c/include/ipc/loc.h

    r0cf27ee r07b39338  
    5757        LOC_SERVICE_GET_NAME,
    5858        LOC_NAMESPACE_GET_ID,
     59        LOC_CALLBACK_CREATE,
    5960        LOC_CATEGORY_GET_ID,
     61        LOC_CATEGORY_GET_NAME,
    6062        LOC_CATEGORY_GET_SVCS,
    6163        LOC_ID_PROBE,
     
    6870        LOC_GET_SERVICES
    6971} loc_request_t;
     72
     73typedef enum {
     74        LOC_EVENT_CAT_CHANGE = IPC_FIRST_USER_METHOD
     75} loc_event_t;
    7076
    7177/** Ports provided by location service.
  • uspace/lib/c/include/ipc/vfs.h

    r0cf27ee r07b39338  
    6262typedef enum {
    6363        VFS_IN_OPEN = IPC_FIRST_USER_METHOD,
    64         VFS_IN_OPEN_NODE,
    6564        VFS_IN_READ,
    6665        VFS_IN_WRITE,
     
    7877        VFS_IN_RENAME,
    7978        VFS_IN_STAT,
    80         VFS_IN_DUP
     79        VFS_IN_DUP,
     80        VFS_IN_WAIT_HANDLE,
    8181} vfs_in_request_t;
    8282
  • uspace/lib/c/include/loader/loader.h

    r0cf27ee r07b39338  
    3838
    3939#include <task.h>
    40 #include <vfs/vfs.h>
    4140
    4241/** Forward declararion */
     
    5049extern int loader_set_pathname(loader_t *, const char *);
    5150extern int loader_set_args(loader_t *, const char *const[]);
    52 extern int loader_set_files(loader_t *, fdi_node_t *const[]);
     51extern int loader_set_files(loader_t *, int *const[]);
    5352extern int loader_load_program(loader_t *);
    5453extern int loader_run(loader_t *);
  • uspace/lib/c/include/loader/pcb.h

    r0cf27ee r07b39338  
    3838
    3939#include <sys/types.h>
    40 #include <vfs/vfs.h>
    4140
    4241typedef void (*entry_point_t)(void);
     
    6261       
    6362        /** Number of preset files. */
    64         int filc;
    65         /** Preset files. */
    66         fdi_node_t **filv;
     63        unsigned int filc;
    6764       
    6865        /*
  • uspace/lib/c/include/loc.h

    r0cf27ee r07b39338  
    4040#include <bool.h>
    4141
     42typedef void (*loc_cat_change_cb_t)(void);
     43
    4244extern async_exch_t *loc_exchange_begin_blocking(loc_interface_t);
    4345extern async_exch_t *loc_exchange_begin(loc_interface_t);
     
    4850extern int loc_service_register_with_iface(const char *, service_id_t *,
    4951    sysarg_t);
     52extern int loc_service_unregister(service_id_t);
    5053extern int loc_service_add_to_cat(service_id_t, category_id_t);
    5154
     
    7376extern size_t loc_get_services(service_id_t, loc_sdesc_t **);
    7477extern int loc_get_categories(category_id_t **, size_t *);
     78extern int loc_register_cat_change_cb(loc_cat_change_cb_t);
    7579
    7680
  • uspace/lib/c/include/task.h

    r0cf27ee r07b39338  
    3737
    3838#include <sys/types.h>
    39 #include <vfs/vfs.h>
    4039
    4140typedef uint64_t task_id_t;
     
    5352extern int task_spawnv(task_id_t *, const char *path, const char *const []);
    5453extern int task_spawnvf(task_id_t *, const char *path, const char *const [],
    55     fdi_node_t *const []);
     54    int *const []);
    5655extern int task_spawnl(task_id_t *, const char *path, ...);
    5756
  • uspace/lib/c/include/vfs/vfs.h

    r0cf27ee r07b39338  
    4040#include <ipc/loc.h>
    4141#include <stdio.h>
     42#include <async.h>
    4243
    43 /** Libc version of the VFS triplet.
    44  *
    45  * Unique identification of a file system node
    46  * within a file system instance.
    47  *
    48  */
    49 typedef struct {
    50         fs_handle_t fs_handle;
    51         service_id_t service_id;
    52         fs_index_t index;
    53 } fdi_node_t;
     44enum vfs_change_state_type {
     45        VFS_PASS_HANDLE
     46};
    5447
    5548extern char *absolutize(const char *, size_t *);
     
    5952extern int unmount(const char *);
    6053
    61 extern int open_node(fdi_node_t *, int);
    62 extern int fd_node(int, fdi_node_t *);
     54extern int fhandle(FILE *, int *);
    6355
    64 extern FILE *fopen_node(fdi_node_t *, const char *);
    65 extern int fnode(FILE *, fdi_node_t *);
     56extern int fd_wait(void);
     57
     58extern async_exch_t *vfs_exchange_begin(void);
     59extern void vfs_exchange_end(async_exch_t *);
    6660
    6761#endif
Note: See TracChangeset for help on using the changeset viewer.