Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ad211c8 in mainline


Ignore:
Timestamp:
2019-12-10T13:49:37Z (12 months ago)
Author:
Martin Decky <martin@…>
Branches:
master
Children:
a6302ae
Parents:
d2e0af47
Message:

remove unnecessary SYSCALL_END

The size of the syscall table is computed statically using the
sizeof_array() macro. Also there is no reason to make the syscall table
a global symbol.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • abi/include/abi/syscall.h

    rd2e0af47 rad211c8  
    108108        SYS_DEBUG_CONSOLE,
    109109
    110         SYS_KLOG,
    111 
    112         SYSCALL_END
     110        SYS_KLOG
    113111} syscall_t;
    114112
  • kernel/generic/include/macros.h

    rd2e0af47 rad211c8  
    164164            ((void *) &(((type *) 0)->member_identif))))
    165165
     166/** Get the size of an array in array elements
     167 *
     168 * @param array Array to determine the size of
     169 *
     170 * @return Size of array in array elements
     171 *
     172 */
     173#define sizeof_array(array) \
     174        (sizeof(array) / sizeof((array)[0]))
     175
    166176#endif
    167177
  • kernel/generic/include/syscall/syscall.h

    rd2e0af47 rad211c8  
    4242    sysarg_t, sysarg_t);
    4343
    44 extern syshandler_t syscall_table[SYSCALL_END];
    4544extern sysarg_t syscall_handler(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
    4645    sysarg_t, sysarg_t, sysarg_t);
  • kernel/generic/src/syscall/syscall.c

    rd2e0af47 rad211c8  
    5656#include <log.h>
    5757
    58 /** Dispatch system call */
    59 sysarg_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 
    120 syshandler_t syscall_table[SYSCALL_END] = {
     58static syshandler_t syscall_table[] = {
    12159        /* System management syscalls. */
    12260        [SYS_KIO] = (syshandler_t) sys_kio,
     
    198136};
    199137
     138/** Dispatch system call */
     139sysarg_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.