src/C/softirq.c
static void softirq_handler_syscall(softirq_t * sfq)
{
    svcnum_t svc = 0;
    uint32_t *args = 0;
    char *svcptr = 0;
    uint32_t syscall = 0;
    stack_frame_t *frame = sfq->caller->ctx[TASK_MODE_MAINTHREAD].frame;

    // let's execute the effective content of the syscall from the userspace task
    // FIXME: [PTH] svc is 8bits on Thumb2, to be updated for portability
    svcptr = (char *)frame->pc;
    svc = (uint32_t) svcptr[-2];
    args = (uint32_t *) frame->r0;

    if (svc != 0) {
        dbg_log("unsupported system call svc=%d!\n", svc);
        dbg_flush();
    }

    syscall = (uint32_t) args[0];

    /*
     * TODO: Hardcoded TASK_MODE_MAINTHREAD should be replaced by the
     * caller task current mode at svc handler time, passed through
     * softirq_query, using the same mechanism as svc_handler_syscalls().
     */
    KERNLOG(DBG_DEBUG, "Executing syscall %d for task %s\n", syscall,
            sfq->caller->name);
    switch (syscall) {
        case SYS_YIELD:
            sys_yield(sfq->caller, TASK_MODE_MAINTHREAD);
            break;
        case SYS_RESET:
            sys_reset(sfq->caller, TASK_MODE_MAINTHREAD);
            break;
        case SYS_SLEEP:
            sys_sleep(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_LOCK:
            sys_lock(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_INIT:
            sys_init(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_IPC:
            sys_ipc(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_CFG:
            sys_cfg(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_GETTICK:
            sys_gettick(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_GET_RANDOM:
            sys_get_random(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_LOG:
            sys_log(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        default:
            WARN("Unknown syscall %d for task %s\n", syscall, sfq->caller->name);
            break;
    }
    return;
}
/*
** Handler managing syscalls (svc 0) waiting for execution in the softirq input queue
*/
Handler managing syscalls (svc 0) waiting for execution in the softirq input queue
Handler managing syscalls ( svc 0 ) waiting for execution in the softirq input queue
static void softirq_handler_syscall(softirq_t * sfq)
{
    svcnum_t svc = 0;
    uint32_t *args = 0;
    char *svcptr = 0;
    uint32_t syscall = 0;
    stack_frame_t *frame = sfq->caller->ctx[TASK_MODE_MAINTHREAD].frame;
    svcptr = (char *)frame->pc;
    svc = (uint32_t) svcptr[-2];
    args = (uint32_t *) frame->r0;
    if (svc != 0) {
        dbg_log("unsupported system call svc=%d!\n", svc);
        dbg_flush();
    }
    syscall = (uint32_t) args[0];
    KERNLOG(DBG_DEBUG, "Executing syscall %d for task %s\n", syscall,
            sfq->caller->name);
    switch (syscall) {
        case SYS_YIELD:
            sys_yield(sfq->caller, TASK_MODE_MAINTHREAD);
            break;
        case SYS_RESET:
            sys_reset(sfq->caller, TASK_MODE_MAINTHREAD);
            break;
        case SYS_SLEEP:
            sys_sleep(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_LOCK:
            sys_lock(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_INIT:
            sys_init(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_IPC:
            sys_ipc(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_CFG:
            sys_cfg(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_GETTICK:
            sys_gettick(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_GET_RANDOM:
            sys_get_random(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        case SYS_LOG:
            sys_log(sfq->caller, &args[1], TASK_MODE_MAINTHREAD);
            break;
        default:
            WARN("Unknown syscall %d for task %s\n", syscall, sfq->caller->name);
            break;
    }
    return;
}
static void softirq_handler_syscall ( softirq_t * sfq ) { svcnum_t svc = 0 ; uint32_t * args = 0 ; char * svcptr = 0 ; uint32_t syscall = 0 ; stack_frame_t * frame = sfq -> caller -> ctx [ TASK_MODE_MAINTHREAD ] . frame ; svcptr = ( char * ) frame -> pc ; svc = ( uint32_t ) svcptr [ -2 ] ; args = ( uint32_t * ) frame -> r0 ; if ( svc != 0 ) { dbg_log ( " \n " , svc ) ; dbg_flush ( ) ; } syscall = ( uint32_t ) args [ 0 ] ; KERNLOG ( DBG_DEBUG , " \n " , syscall , sfq -> caller -> name ) ; switch ( syscall ) { case SYS_YIELD : sys_yield ( sfq -> caller , TASK_MODE_MAINTHREAD ) ; break ; case SYS_RESET : sys_reset ( sfq -> caller , TASK_MODE_MAINTHREAD ) ; break ; case SYS_SLEEP : sys_sleep ( sfq -> caller , & args [ 1 ] , TASK_MODE_MAINTHREAD ) ; break ; case SYS_LOCK : sys_lock ( sfq -> caller , & args [ 1 ] , TASK_MODE_MAINTHREAD ) ; break ; case SYS_INIT : sys_init ( sfq -> caller , & args [ 1 ] , TASK_MODE_MAINTHREAD ) ; break ; case SYS_IPC : sys_ipc ( sfq -> caller , & args [ 1 ] , TASK_MODE_MAINTHREAD ) ; break ; case SYS_CFG : sys_cfg ( sfq -> caller , & args [ 1 ] , TASK_MODE_MAINTHREAD ) ; break ; case SYS_GETTICK : sys_gettick ( sfq -> caller , & args [ 1 ] , TASK_MODE_MAINTHREAD ) ; break ; case SYS_GET_RANDOM : sys_get_random ( sfq -> caller , & args [ 1 ] , TASK_MODE_MAINTHREAD ) ; break ; case SYS_LOG : sys_log ( sfq -> caller , & args [ 1 ] , TASK_MODE_MAINTHREAD ) ; break ; default : WARN ( " \n " , syscall , sfq -> caller -> name ) ; break ; } return ; }
Handler managing syscalls (svc 0) waiting for execution in the softirq input queue
Handler managing syscalls ( svc 0 ) waiting for execution in the softirq input queue
// let's execute the effective content of the syscall from the userspace task // FIXME: [PTH] svc is 8bits on Thumb2, to be updated for portability /*
     * TODO: Hardcoded TASK_MODE_MAINTHREAD should be replaced by the
     * caller task current mode at svc handler time, passed through
     * softirq_query, using the same mechanism as svc_handler_syscalls().
     */