51,15 → 51,14 |
#include <syscall/copy.h> |
#include <sysinfo/sysinfo.h> |
#include <console/console.h> |
#include <console/klog.h> |
#include <udebug/udebug.h> |
|
/** Print using kernel facility |
* |
* Some simulators can print only through kernel. Userspace can use |
* this syscall to facilitate it. |
* Print to kernel log. |
* |
*/ |
static unative_t sys_io(int fd, const void * buf, size_t count) |
static unative_t sys_klog(int fd, const void * buf, size_t count) |
{ |
size_t i; |
char *data; |
67,20 → 66,23 |
|
if (count > PAGE_SIZE) |
return ELIMIT; |
|
data = (char *) malloc(count, 0); |
if (!data) |
return ENOMEM; |
|
rc = copy_from_uspace(data, buf, count); |
if (rc) { |
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); |
return rc; |
} |
|
for (i = 0; i < count; i++) |
putchar(data[i]); |
free(data); |
} else |
klog_update(); |
|
return count; |
} |
106,8 → 108,7 |
udebug_stoppable_begin(); |
rc = syscall_table[id](a1, a2, a3, a4, a5, a6); |
} else { |
klog_printf("TASK %llu: Unknown syscall id %llx", TASK->taskid, |
id); |
printf("Task %" PRIu64": Unknown syscall %#" PRIxn, TASK->taskid, id); |
task_kill(TASK->taskid); |
thread_exit(); |
} |
123,7 → 124,7 |
} |
|
syshandler_t syscall_table[SYSCALL_END] = { |
(syshandler_t) sys_io, |
(syshandler_t) sys_klog, |
(syshandler_t) sys_tls_set, |
|
/* Thread and task related syscalls. */ |
130,7 → 131,9 |
(syshandler_t) sys_thread_create, |
(syshandler_t) sys_thread_exit, |
(syshandler_t) sys_thread_get_id, |
|
(syshandler_t) sys_task_get_id, |
(syshandler_t) sys_task_spawn, |
|
/* Synchronization related syscalls. */ |
(syshandler_t) sys_futex_sleep_timeout, |