summaryrefslogtreecommitdiffstats
path: root/sys/syscall.h
blob: ea751524390788077e48b08074a1451dad422fd9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef _JOVE_SYS_SYSCALL_H
#define _JOVE_SYS_SYSCALL_H 1

#include "api/syscall.h"
#include "hal/obj.h"
#include <stdint.h>

#define CHECK_TOOSMALL(required, present, fail_msg) \
    do { if(present < required) { \
        kprintf("%s: %s\n", __func__, fail_msg); \
        return ETOOSMALL; \
    } } while(0)

#define CHECK_OBJEXISTS(obj, fail_msg) \
do { if(obj == NULL) { \
    kprintf("%s: %s\n", __func__, fail_msg); \
    return EBADOBJ; \
} } while(0)

#define CHECK_OBJTYPE(obj, type, fail_msg) \
    do { if(obj_gettype(obj) != type) { \
        kprintf("%s: %s\n", __func__, fail_msg); \
        return EBADOBJ; \
    } } while(0)

#define SYSCALL_FUNCTION_ARGS \
        jove_owned_obj_t*, /*PCB object*/ \
        jove_owned_obj_t*, /*Objdir object*/ \
        jove_owned_obj_t*, /*Message object*/ \
        jove_owned_obj_t*, /*Target object*/ \
        struct syscall_header*, /*Syscall header*/ \
        size_t, /*How many bytes are left in the message*/ \
        void* /*The bytes left in the message.*/

typedef int (*syscall_handle_t)(SYSCALL_FUNCTION_ARGS);

int _syscall_handle_generic(SYSCALL_FUNCTION_ARGS);
int _syscall_handle_arch(SYSCALL_FUNCTION_ARGS);

int _syscall_handle_vtt(SYSCALL_FUNCTION_ARGS);
int _syscall_handle_objdir(SYSCALL_FUNCTION_ARGS);
int _syscall_handle_untyped(SYSCALL_FUNCTION_ARGS);

#endif