summaryrefslogblamecommitdiffstats
path: root/usr/syscall.c
blob: 86808453429d9bb6a52521a9daf575a2b305319b (plain) (tree)
1
2
3
4
5
6
7
                    
                        




                                                 




                                               




                                             










                                                                  
#include "syscall.h"
#include "tsk/tasking.h"
#include "mem/memory.h"
#include "io/log.h"

int _syscall_handler_log(struct syscall_log *req)
{
    if(!mem_check_ptr(req->message)) return -1;
    klogf("%s", req->message);
    return 0;
}

intmax_t _syscall_handler_tid(syscall_t *req)
{
    return task_current->id;
}

void *_syscall_handlers[SYSCALL_COUNT] = {
    _syscall_handler_log
};

int
syscall_handler(syscall_t *req)
{
    if(!mem_check_ptr(req)) return -1;
    if(req->id >= SYSCALL_COUNT) return -1;
    return ((syscall_handler_t)(_syscall_handlers[req->id]))(req);
}