Changeset 44c6d88d in mainline


Ignore:
Timestamp:
2006-05-30T17:23:33Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
eaf34f7
Parents:
79460ae
Message:

Added some additional functionality.

Location:
libc
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • libc/generic/async.c

    r79460ae r44c6d88d  
    270270}
    271271
     272/** Function that gets created on interrupt receival
     273 *
     274 * This function is defined as a weak symbol - to be redefined in
     275 * user code.
     276 */
     277void interrupt_received(ipc_call_t *call)
     278{
     279}
     280
     281
    272282/** Wrapper for client connection thread
    273283 *
     
    309319 * threads.
    310320 *
     321 * @param in_phone_hash Identification of the incoming connection
    311322 * @param callid Callid of the IPC_M_CONNECT_ME_TO packet
    312323 * @param call Call data of the opening packet
     
    315326 * @return New thread id
    316327 */
    317 pstid_t async_new_connection(ipc_callid_t callid, ipc_call_t *call,
     328pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid,
     329                             ipc_call_t *call,
    318330                             void (*cthread)(ipc_callid_t,ipc_call_t *))
    319331{
     
    327339                return NULL;
    328340        }
    329         conn->in_phone_hash = IPC_GET_ARG3(*call);
     341        conn->in_phone_hash = in_phone_hash;
    330342        list_initialize(&conn->msg_queue);
    331343        conn->ptid = psthread_create(connection_thread, conn);
     
    354366static void handle_call(ipc_callid_t callid, ipc_call_t *call)
    355367{
     368        /* Unrouted call - do some default behaviour */
     369        switch (IPC_GET_METHOD(*call)) {
     370        case IPC_M_INTERRUPT:
     371                interrupt_received(call);
     372                return;
     373        case IPC_M_CONNECT_ME_TO:
     374                /* Open new connection with thread etc. */
     375                async_new_connection(IPC_GET_ARG3(*call), callid, call, client_connection);
     376                return;
     377        }
     378
     379        /* Try to route call through connection tables */
    356380        if (route_call(callid, call))
    357381                return;
    358382
    359         switch (IPC_GET_METHOD(*call)) {
    360         case IPC_M_INTERRUPT:
    361                 break;
    362         case IPC_M_CONNECT_ME_TO:
    363                 /* Open new connection with thread etc. */
    364                 async_new_connection(callid, call, client_connection);
    365                 break;
    366         default:
    367                 ipc_answer_fast(callid, EHANGUP, 0, 0);
    368         }
     383        /* Unknown call from unknown phone - hang it up */
     384        ipc_answer_fast(callid, EHANGUP, 0, 0);
    369385}
    370386
     
    622638}
    623639
     640/** Wait specified time, but in the meantime handle incoming events
     641 *
     642 * @param timeout Time in microseconds to wait
     643 */
     644void async_usleep(suseconds_t timeout)
     645{
     646        amsg_t *msg;
     647       
     648        msg = malloc(sizeof(*msg));
     649        if (!msg)
     650                return;
     651
     652        msg->ptid = psthread_get_id();
     653        msg->active = 0;
     654        msg->has_timeout = 1;
     655
     656        gettimeofday(&msg->expires, NULL);
     657        tv_add(&msg->expires, timeout);
     658
     659        futex_down(&async_futex);
     660        insert_timeout(msg);
     661        /* Leave locked async_futex when entering this function */
     662        psthread_schedule_next_adv(PS_TO_MANAGER);
     663        /* futex is up automatically after psthread_schedule_next...*/
     664        free(msg);
     665}
  • libc/generic/io/stream.c

    r79460ae r44c6d88d  
    6565        if (console_phone < 0) {
    6666                while ((console_phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0)) < 0) {
    67                         volatile int a;
    68                         for (a = 0; a < 1048576; a++);
     67                        usleep(10000);
    6968                }
    7069        }
  • libc/generic/time.c

    r79460ae r44c6d88d  
    3232#include <stdio.h>
    3333#include <arch/barrier.h>
     34#include <unistd.h>
     35#include <atomic.h>
     36#include <futex.h>
    3437
    3538#include <sysinfo.h>
     
    9497        return 0;
    9598}
     99
     100/** Wait unconditionally for specified miliseconds */
     101void usleep(unsigned long usec)
     102{
     103        atomic_t futex = FUTEX_INITIALIZER;
     104
     105        futex_initialize(&futex,0);
     106        futex_down_timeout(&futex, usec, 0);
     107}
  • libc/include/async.h

    r79460ae r44c6d88d  
    1414ipc_callid_t async_get_call(ipc_call_t *data);
    1515
    16 pstid_t async_new_connection(ipc_callid_t callid, ipc_call_t *call,
    17                              void (*cthread)(ipc_callid_t,ipc_call_t *));
    1816aid_t async_send_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
    1917                   ipc_call_t *dataptr);
    2018void async_wait_for(aid_t amsgid, ipcarg_t *result);
    2119int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout);
    22 
     20pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid,
     21                             ipc_call_t *call,
     22                             void (*cthread)(ipc_callid_t,ipc_call_t *));
     23void async_usleep(suseconds_t timeout);
    2324
    2425/* Should be defined by application */
    2526void client_connection(ipc_callid_t callid, ipc_call_t *call) __attribute__((weak));
     27void interrupt_received(ipc_call_t *call)  __attribute__((weak));
    2628
    2729#endif
  • libc/include/unistd.h

    r79460ae r44c6d88d  
    3939extern void _exit(int status);
    4040void *sbrk(ssize_t incr);
     41void usleep(unsigned long usec);
    4142
    4243#endif
Note: See TracChangeset for help on using the changeset viewer.