summaryrefslogtreecommitdiffstats
path: root/abi/syscall.h
blob: 54a67b9ba56edbd4f93755692293a39f492a0d34 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef JOVE_ABI_SYSCALL_H
#define JOVE_ABI_SYSCALL_H 1

#include <stdint.h>

typedef struct syscall {
    int id;
} syscall_t;

struct syscall_log {
    syscall_t syscall;
    const char *message;
};

struct syscall_tid {
    syscall_t syscall;
    intmax_t value;
};

struct syscall_mem_map {
    syscall_t syscall;
    uintptr_t phys;
    uintptr_t virt;
    intmax_t tid;
};

enum
{
    SYSCALL_LOG = 0,
    SYSCALL_TID,
    SYSCALL_MEM_MAP,
    SYSCALL_COUNT
};

#define _SYSCALL(data) \
    intmax_t ax; \
    __asm__ volatile("movq %0, %%rdi\nsyscall": "=a"(ax): "r"(data): "memory"); \
    return ax

int _syscall_log(const char *message) {
    struct syscall_log syscall_data = {
        .syscall = (syscall_t){ .id = SYSCALL_LOG },
        .message = message
    };
    _SYSCALL(&syscall_data);
}

intmax_t _syscall_tid(void) {
    syscall_t syscall_data = { SYSCALL_TID };
    _SYSCALL(&syscall_data);
}

void __syscall_mem_map(uintptr_t phys, uintptr_t virt, intmax_t tid)
{
    
}

#endif