42,59 → 42,18 |
#include <mm/as.h> |
#include <print.h> |
#include <putchar.h> |
#include <errno.h> |
#include <arch.h> |
#include <debug.h> |
#include <ddi/device.h> |
#include <ipc/sysipc.h> |
#include <synch/futex.h> |
#include <synch/smc.h> |
#include <ddi/ddi.h> |
#include <security/cap.h> |
#include <syscall/copy.h> |
#include <sysinfo/sysinfo.h> |
#include <console/console.h> |
#include <udebug/udebug.h> |
|
/** Print using kernel facility |
* |
* Print to kernel log. |
* |
*/ |
static unative_t sys_klog(int fd, const void * buf, size_t count) |
{ |
size_t i; |
char *data; |
int rc; |
|
if (count > PAGE_SIZE) |
return ELIMIT; |
|
if (count > 0) { |
data = (char *) malloc(count, 0); |
if (!data) |
return ENOMEM; |
|
rc = copy_from_uspace(data, buf, count); |
if (rc) { |
free(data); |
return rc; |
} |
|
for (i = 0; i < count; i++) |
putchar(data[i]); |
free(data); |
} else |
klog_update(); |
|
return count; |
} |
|
/** Tell kernel to get keyboard/console access again */ |
static unative_t sys_debug_enable_console(void) |
{ |
arch_grab_console(); |
return 0; |
} |
|
/** Dispatch system call */ |
unative_t syscall_handler(unative_t a1, unative_t a2, unative_t a3, |
unative_t a4, unative_t a5, unative_t a6, unative_t id) |
101,9 → 60,13 |
{ |
unative_t rc; |
|
if (id < SYSCALL_END) |
#ifdef CONFIG_UDEBUG |
udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, 0, false); |
#endif |
|
if (id < SYSCALL_END) { |
rc = syscall_table[id](a1, a2, a3, a4, a5, a6); |
else { |
} else { |
printf("Task %" PRIu64": Unknown syscall %#" PRIxn, TASK->taskid, id); |
task_kill(TASK->taskid); |
thread_exit(); |
112,6 → 75,17 |
if (THREAD->interrupted) |
thread_exit(); |
|
#ifdef CONFIG_UDEBUG |
udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, rc, true); |
|
/* |
* Stopping point needed for tasks that only invoke non-blocking |
* system calls. |
*/ |
udebug_stoppable_begin(); |
udebug_stoppable_end(); |
#endif |
|
return rc; |
} |
|
125,6 → 99,7 |
(syshandler_t) sys_thread_get_id, |
|
(syshandler_t) sys_task_get_id, |
(syshandler_t) sys_task_set_name, |
(syshandler_t) sys_program_spawn_loader, |
|
/* Synchronization related syscalls. */ |
146,6 → 121,7 |
(syshandler_t) sys_ipc_answer_fast, |
(syshandler_t) sys_ipc_answer_slow, |
(syshandler_t) sys_ipc_forward_fast, |
(syshandler_t) sys_ipc_forward_slow, |
(syshandler_t) sys_ipc_wait_for_call, |
(syshandler_t) sys_ipc_hangup, |
(syshandler_t) sys_ipc_register_irq, |
156,6 → 132,7 |
(syshandler_t) sys_cap_revoke, |
|
/* DDI related syscalls. */ |
(syshandler_t) sys_device_assign_devno, |
(syshandler_t) sys_physmem_map, |
(syshandler_t) sys_iospace_enable, |
(syshandler_t) sys_preempt_control, |
165,7 → 142,10 |
(syshandler_t) sys_sysinfo_value, |
|
/* Debug calls */ |
(syshandler_t) sys_debug_enable_console |
(syshandler_t) sys_debug_enable_console, |
(syshandler_t) sys_debug_disable_console, |
|
(syshandler_t) sys_ipc_connect_kbox |
}; |
|
/** @} |