Subversion Repositories HelenOS

Rev

Rev 3018 | Rev 3425 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3018 Rev 3424
Line 49... Line 49...
49
#include <ddi/ddi.h>
49
#include <ddi/ddi.h>
50
#include <security/cap.h>
50
#include <security/cap.h>
51
#include <syscall/copy.h>
51
#include <syscall/copy.h>
52
#include <sysinfo/sysinfo.h>
52
#include <sysinfo/sysinfo.h>
53
#include <console/console.h>
53
#include <console/console.h>
54
#include <console/klog.h>
-
 
55
#include <udebug/udebug.h>
54
#include <udebug/udebug.h>
56
 
55
 
57
/** Print using kernel facility
56
/** Print using kernel facility
58
 *
57
 *
59
 * Some simulators can print only through kernel. Userspace can use
-
 
60
 * this syscall to facilitate it.
58
 * Print to kernel log.
-
 
59
 *
61
 */
60
 */
62
static unative_t sys_io(int fd, const void * buf, size_t count)
61
static unative_t sys_klog(int fd, const void * buf, size_t count)
63
{
62
{
64
    size_t i;
63
    size_t i;
65
    char *data;
64
    char *data;
66
    int rc;
65
    int rc;
67
 
66
 
68
    if (count > PAGE_SIZE)
67
    if (count > PAGE_SIZE)
69
        return ELIMIT;
68
        return ELIMIT;
70
 
-
 
71
    data = (char *) malloc(count, 0);
-
 
72
    if (!data)
-
 
73
        return ENOMEM;
-
 
74
   
69
   
-
 
70
    if (count > 0) {
-
 
71
        data = (char *) malloc(count, 0);
-
 
72
        if (!data)
-
 
73
            return ENOMEM;
-
 
74
       
75
    rc = copy_from_uspace(data, buf, count);
75
        rc = copy_from_uspace(data, buf, count);
76
    if (rc) {
76
        if (rc) {
-
 
77
            free(data);
-
 
78
            return rc;
-
 
79
        }
-
 
80
   
-
 
81
        for (i = 0; i < count; i++)
-
 
82
            putchar(data[i]);
77
        free(data);
83
        free(data);
78
        return rc;
-
 
79
    }
84
    } else
80
 
-
 
81
    for (i = 0; i < count; i++)
-
 
82
        putchar(data[i]);
85
        klog_update();
83
    free(data);
-
 
84
   
86
   
85
    return count;
87
    return count;
86
}
88
}
87
 
89
 
88
/** Tell kernel to get keyboard/console access again */
90
/** Tell kernel to get keyboard/console access again */
Line 104... Line 106...
104
 
106
 
105
    if (id < SYSCALL_END) {
107
    if (id < SYSCALL_END) {
106
        udebug_stoppable_begin();
108
        udebug_stoppable_begin();
107
        rc = syscall_table[id](a1, a2, a3, a4, a5, a6);
109
        rc = syscall_table[id](a1, a2, a3, a4, a5, a6);
108
    } else {
110
    } else {
109
        klog_printf("TASK %llu: Unknown syscall id %llx", TASK->taskid,
111
        printf("Task %" PRIu64": Unknown syscall %#" PRIxn, TASK->taskid, id);
110
            id);
-
 
111
        task_kill(TASK->taskid);
112
        task_kill(TASK->taskid);
112
        thread_exit();
113
        thread_exit();
113
    }
114
    }
114
       
115
       
115
    if (THREAD->interrupted)
116
    if (THREAD->interrupted)
Line 121... Line 122...
121
   
122
   
122
    return rc;
123
    return rc;
123
}
124
}
124
 
125
 
125
syshandler_t syscall_table[SYSCALL_END] = {
126
syshandler_t syscall_table[SYSCALL_END] = {
126
    (syshandler_t) sys_io,
127
    (syshandler_t) sys_klog,
127
    (syshandler_t) sys_tls_set,
128
    (syshandler_t) sys_tls_set,
128
   
129
   
129
    /* Thread and task related syscalls. */
130
    /* Thread and task related syscalls. */
130
    (syshandler_t) sys_thread_create,
131
    (syshandler_t) sys_thread_create,
131
    (syshandler_t) sys_thread_exit,
132
    (syshandler_t) sys_thread_exit,
132
    (syshandler_t) sys_thread_get_id,
133
    (syshandler_t) sys_thread_get_id,
-
 
134
   
133
    (syshandler_t) sys_task_get_id,
135
    (syshandler_t) sys_task_get_id,
-
 
136
    (syshandler_t) sys_task_spawn,
134
   
137
   
135
    /* Synchronization related syscalls. */
138
    /* Synchronization related syscalls. */
136
    (syshandler_t) sys_futex_sleep_timeout,
139
    (syshandler_t) sys_futex_sleep_timeout,
137
    (syshandler_t) sys_futex_wakeup,
140
    (syshandler_t) sys_futex_wakeup,
138
   
141