MCPcopy Create free account
hub / github.com/HelenOS/helenos / syscall_handler

Function syscall_handler

kernel/generic/src/syscall/syscall.c:139–198  ·  view source on GitHub ↗

Dispatch system call */

Source from the content-addressed store, hash-verified

137
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

Callers 3

swi_exceptionFunction · 0.85
break_instructionFunction · 0.85

Calls 10

irq_spinlock_lockFunction · 0.85
thread_update_accountingFunction · 0.85
irq_spinlock_unlockFunction · 0.85
istate_getFunction · 0.85
udebug_syscall_eventFunction · 0.85
task_kill_selfFunction · 0.85
udebug_stoppable_beginFunction · 0.85
udebug_stoppable_endFunction · 0.85
logFunction · 0.50
thread_exitFunction · 0.50

Tested by

no test coverage detected