Changeset 921b84f in mainline for uspace/lib/c


Ignore:
Timestamp:
2011-08-19T17:36:25Z (14 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5fb32c5
Parents:
ea186c6 (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 changes.

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

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/ia32/Makefile.common

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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/src/entry.S

    rea186c6 r921b84f  
    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/generic/async.c

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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       
     
    342342}
    343343
    344 int devman_device_get_handle(const char *pathname, devman_handle_t *handle,
     344int devman_fun_get_handle(const char *pathname, devman_handle_t *handle,
    345345    unsigned int flags)
    346346{
     
    383383}
    384384
    385 int devman_get_device_path(devman_handle_t handle, char *path, size_t path_size)
     385static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, char *buf,
     386    size_t buf_size)
     387{
     388        async_exch_t *exch;
     389        ipc_call_t dreply;
     390        size_t act_size;
     391        sysarg_t dretval;
     392       
     393        exch = devman_exchange_begin_blocking(LOC_PORT_CONSUMER);
     394       
     395        ipc_call_t answer;
     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);
     450       
     451        if (retval != EOK) {
     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)
    386513{
    387514        async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
     
    389516                return ENOMEM;
    390517       
    391         ipc_call_t answer;
    392         aid_t req = async_send_1(exch, DEVMAN_DEVICE_GET_DEVICE_PATH,
    393             handle, &answer);
    394        
    395         ipc_call_t data_request_call;
    396         aid_t data_request = async_data_read(exch, path, path_size,
    397             &data_request_call);
    398        
    399         devman_exchange_end(exch);
    400        
    401         if (data_request == 0) {
    402                 async_wait_for(req, NULL);
    403                 return ENOMEM;
    404         }
    405        
    406         sysarg_t data_request_rc;
    407         async_wait_for(data_request, &data_request_rc);
    408        
    409         sysarg_t opening_request_rc;
    410         async_wait_for(req, &opening_request_rc);
    411        
    412         if (data_request_rc != EOK) {
    413                 /* Prefer the return code of the opening request. */
    414                 if (opening_request_rc != EOK)
    415                         return (int) opening_request_rc;
    416                 else
    417                         return (int) data_request_rc;
    418         }
    419        
    420         if (opening_request_rc != EOK)
    421                 return (int) opening_request_rc;
    422        
    423         /* To be on the safe-side. */
    424         path[path_size - 1] = 0;
    425         size_t transferred_size = IPC_GET_ARG2(data_request_call);
    426         if (transferred_size >= path_size)
    427                 return ELIMIT;
    428        
    429         /* Terminate the string (trailing 0 not send over IPC). */
    430         path[transferred_size] = 0;
    431         return EOK;
     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);
    432530}
    433531
  • uspace/lib/c/generic/event.c

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    315315/** Register new service.
    316316 *
    317  * @param fqsn  Fully qualified service name
    318  * @param sid   Output: ID of new service
     317 * @param fqsn Fully qualified service name
     318 * @param sid  Output: ID of new service
    319319 *
    320320 */
  • uspace/lib/c/generic/private/async.h

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    5656    unsigned int);
    5757
    58 extern int devman_device_get_handle(const char *, devman_handle_t *,
     58extern int devman_fun_get_handle(const char *, devman_handle_t *,
    5959    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
    6266extern int devman_add_device_to_category(devman_handle_t, const char *);
  • uspace/lib/c/include/event.h

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    149149typedef enum {
    150150        DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD,
    151         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,
    152155        DEVMAN_FUN_SID_TO_HANDLE
    153156} client_to_devman_t;
  • uspace/lib/c/include/ipc/vfs.h

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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/task.h

    rea186c6 r921b84f  
    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

    rea186c6 r921b84f  
    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.