summaryrefslogtreecommitdiffstats
path: root/sys/syscall.h
blob: d8b64bbd953ee24261761f378c94bf699b1c745a (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
59
60
61
62
63
64
65
66
67
68
69
#ifndef _SYS_SYSCALL_H
#define _SYS_SYSCALL_H 1

#include <stdint.h>
#include <stddef.h>
#include "types.h"

typedef struct syscall {
    int id;
} syscall_t;

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

struct syscall_mem_phys_range_op {
    syscall_t syscall;
    uintptr_t base;
    uintptr_t limit;
};

struct syscall_mem_phys_alloc {
    syscall_t syscall;
    size_t npages;
    uintptr_t *result;
};

struct syscall_mem_virt_mapping {
    syscall_t syscall;
    linear_address_t addr;
    page_mapping_t *result;
};

struct syscall_mem_virt_map {
    syscall_t syscall;
    linear_address_t addr;
    page_mapping_t map;
};

struct syscall_mem_virt_alloc {
    syscall_t syscall;
    linear_address_t from;
    uintptr_t to;
    page_flags_t flg;
};

enum
{
    SYSCALL_LOG = 0,
    SYSCALL_TID,

    SYSCALL_MEM_PHYS_RESV,
    SYSCALL_MEM_PHYS_FREE,
    SYSCALL_MEM_PHYS_ALLOC,

    SYSCALL_MEM_VIRT_MAPPING,
    SYSCALL_MEM_VIRT_MAP,
    SYSCALL_MEM_VIRT_ALLOC,

    SYSCALL_COUNT
};

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

#endif