Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/syscall/syscall.c

    rad211c8 r3b3fcf36  
    5656#include <log.h>
    5757
    58 static syshandler_t syscall_table[] = {
     58/** Dispatch system call */
     59sysarg_t syscall_handler(sysarg_t a1, sysarg_t a2, sysarg_t a3,
     60    sysarg_t a4, sysarg_t a5, sysarg_t a6, sysarg_t id)
     61{
     62        /* Do userpace accounting */
     63        irq_spinlock_lock(&THREAD->lock, true);
     64        thread_update_accounting(true);
     65        irq_spinlock_unlock(&THREAD->lock, true);
     66
     67#ifdef CONFIG_UDEBUG
     68        /*
     69         * An istate_t-compatible record was created on the stack by the
     70         * low-level syscall handler. This is the userspace space state
     71         * structure.
     72         */
     73        THREAD->udebug.uspace_state = istate_get(THREAD);
     74
     75        /*
     76         * Early check for undebugged tasks. We do not lock anything as this
     77         * test need not be precise in either direction.
     78         */
     79        if (THREAD->udebug.active)
     80                udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, 0, false);
     81#endif
     82
     83        sysarg_t rc;
     84        if (id < SYSCALL_END) {
     85                rc = syscall_table[id](a1, a2, a3, a4, a5, a6);
     86        } else {
     87                log(LF_OTHER, LVL_ERROR,
     88                    "Task %" PRIu64 ": Unknown syscall %#" PRIxn, TASK->taskid, id);
     89                task_kill_self(true);
     90        }
     91
     92        if (THREAD->interrupted)
     93                thread_exit();
     94
     95#ifdef CONFIG_UDEBUG
     96        if (THREAD->udebug.active) {
     97                udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, rc, true);
     98
     99                /*
     100                 * Stopping point needed for tasks that only invoke
     101                 * non-blocking system calls. Not needed if the task
     102                 * is not being debugged (it cannot block here).
     103                 */
     104                udebug_stoppable_begin();
     105                udebug_stoppable_end();
     106        }
     107
     108        /* Clear userspace state pointer */
     109        THREAD->udebug.uspace_state = NULL;
     110#endif
     111
     112        /* Do kernel accounting */
     113        irq_spinlock_lock(&THREAD->lock, true);
     114        thread_update_accounting(false);
     115        irq_spinlock_unlock(&THREAD->lock, true);
     116
     117        return rc;
     118}
     119
     120syshandler_t syscall_table[SYSCALL_END] = {
    59121        /* System management syscalls. */
    60122        [SYS_KIO] = (syshandler_t) sys_kio,
     
    136198};
    137199
    138 /** Dispatch system call */
    139 sysarg_t syscall_handler(sysarg_t a1, sysarg_t a2, sysarg_t a3,
    140     sysarg_t a4, sysarg_t a5, sysarg_t a6, sysarg_t id)
    141 {
    142         /* Do userpace accounting */
    143         irq_spinlock_lock(&THREAD->lock, true);
    144         thread_update_accounting(true);
    145         irq_spinlock_unlock(&THREAD->lock, true);
    146 
    147 #ifdef CONFIG_UDEBUG
    148         /*
    149          * An istate_t-compatible record was created on the stack by the
    150          * low-level syscall handler. This is the userspace space state
    151          * structure.
    152          */
    153         THREAD->udebug.uspace_state = istate_get(THREAD);
    154 
    155         /*
    156          * Early check for undebugged tasks. We do not lock anything as this
    157          * test need not be precise in either direction.
    158          */
    159         if (THREAD->udebug.active)
    160                 udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, 0, false);
    161 #endif
    162 
    163         sysarg_t rc;
    164         if (id < sizeof_array(syscall_table)) {
    165                 rc = syscall_table[id](a1, a2, a3, a4, a5, a6);
    166         } else {
    167                 log(LF_OTHER, LVL_ERROR,
    168                     "Task %" PRIu64 ": Unknown syscall %#" PRIxn, TASK->taskid, id);
    169                 task_kill_self(true);
    170         }
    171 
    172         if (THREAD->interrupted)
    173                 thread_exit();
    174 
    175 #ifdef CONFIG_UDEBUG
    176         if (THREAD->udebug.active) {
    177                 udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, rc, true);
    178 
    179                 /*
    180                  * Stopping point needed for tasks that only invoke
    181                  * non-blocking system calls. Not needed if the task
    182                  * is not being debugged (it cannot block here).
    183                  */
    184                 udebug_stoppable_begin();
    185                 udebug_stoppable_end();
    186         }
    187 
    188         /* Clear userspace state pointer */
    189         THREAD->udebug.uspace_state = NULL;
    190 #endif
    191 
    192         /* Do kernel accounting */
    193         irq_spinlock_lock(&THREAD->lock, true);
    194         thread_update_accounting(false);
    195         irq_spinlock_unlock(&THREAD->lock, true);
    196 
    197         return rc;
    198 }
    199 
    200200/** @}
    201201 */
Note: See TracChangeset for help on using the changeset viewer.