summaryrefslogtreecommitdiffstats
path: root/api/syscall.h
blob: a11617748c1917512ce67edaac38271f1819116c (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#ifndef _JOVE_API_SYSCALL_H
#define _JOVE_API_SYSCALL_H 1

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

#include "obj.h"

/* General syscall behavior:
 * If the message passed is not a JOVE_OBJ_MESSAGE type, the kernel will return EBADOBJ.
 * If the message is too small to hold the target path, the kernel will return ETOOSMALL.
 * If the target path does not target a real object, the kernel will return EBADPATH.
 * If the target does not support the callid, the kernel will return EBADARG.
 * Otherwise, behavior depends on the syscall specified in callid.
 * */

struct syscall_header
{
    uint16_t callid;
    uint16_t pathlen;
    objpath_part_t path[];
};

/* If the message is too small for data, the kernel will return ETOOSMALL.
 * */
struct syscall_generic_write
{
    size_t len;
    char data[];
};

struct syscall_generic_objpath
{
    uint16_t pathlen;
    objpath_part_t path[];
};

/**JOVE_OBJ_UNTYPED syscalls.
 * */

enum
{
    _SYSCALL_UNTYPED_BADCALL = 0,
    SYSCALL_UNTYPED_ADDRESS,
    SYSCALL_UNTYPED_SIZE,
    SYSCALL_UNTYPED_SPLIT,
    SYSCALL_UNTYPED_MERGE,
    SYSCALL_UNTYPED_RETYPE,
};

#define SYSCALL_PERM_UNTYPED_ADDRESS JOVE_PERM_READ
#define SYSCALL_PERM_UNTYPED_SIZE JOVE_PERM_READ
#define SYSCALL_PERM_UNTYPED_SPLIT (JOVE_PERM_WRITE | JOVE_PERM_MUTATE)
#define SYSCALL_PERM_UNTYPED_MERGE (JOVE_PERM_WRITE | JOVE_PERM_MUTATE)

struct syscall_untyped_split
{
    size_t bytes;
    uint16_t dest_pathlen;
    objpath_part_t dest_path[];
};

/**JOVE_OBJ_OBJDIR syscalls.
 * */

enum
{
    _SYSCALL_OBJDIR_BADCALL = 0,
    SYSCALL_OBJDIR_OBJTYPE,
};

#define SYSCALL_PERM_OBJDIR_OBJTYPE JOVE_PERM_READ

/* JOVE_OBJ_PAGEDIR syscalls
 * */

enum
{
    _SYSCALL_PAGEDIR_NONE = 0,
    SYSCALL_PAGEDIR_MAP_FRAME,
    SYSCALL_PAGEDIR_MAP_TABLE,
    SYSCALL_PAGEDIR_MAP_SHMEM,
    SYSCALL_PAGEDIR_UNMAP_FRAME,
    SYSCALL_PAGEDIR_UNMAP_TABLE,
    SYSCALL_PAGEDIR_UNMAP_SHMEM,
};

#define SYSCALL_PERM_PAGEDIR_MAP_FRAME (JOVE_PERM_READ | JOVE_PERM_WRITE)
#define SYSCALL_PERM_PAGEDIR_MAP_TABLE (JOVE_PERM_READ | JOVE_PERM_WRITE)
#define SYSCALL_PERM_PAGEDIR_MAP_SHMEM (JOVE_PERM_READ | JOVE_PERM_WRITE)
#define SYSCALL_PERM_PAGEDIR_UNMAP_FRAME (JOVE_PERM_READ | JOVE_PERM_WRITE)
#define SYSCALL_PERM_PAGEDIR_UNMAP_TABLE (JOVE_PERM_READ | JOVE_PERM_WRITE)
#define SYSCALL_PERM_PAGEDIR_UNMAP_SHMEM (JOVE_PERM_READ | JOVE_PERM_WRITE)

struct syscall_pagedir_flags
{
    uint8_t writeable : 1;
    uint8_t executable : 1;
    uint8_t flg_unused : 6;
};

struct syscall_pagedir_map
{
    struct syscall_pagedir_flags page_flags;
    uint16_t untyped_pathlen;
    uintptr_t virtual_address;
    objpath_part_t untyped_path[];
};

struct syscall_pagedir_map_shmem
{
    struct syscall_pagedir_flags page_flags;
    uint8_t page_offset;
    uint16_t shmem_pathlen;
    uintptr_t virtual_address;
    objpath_part_t shmem_path[];
};

struct syscall_pagedir_unmap
{
    uintptr_t virtual_address;
    uint16_t none_pathlen;
    objpath_part_t none_path[];
};

/**JOVE_OBJ_INITRD_FILE syscalls
 * */

enum
{
    _SYSCALL_INITRD_FILE_NONE = 0,
    SYSCALL_INITRD_FILE_NAME,
    SYSCALL_INITRD_FILE_SIZE,
    SYSCALL_INITRD_FILE_READ
};

#define SYSCALL_PERM_INITRD_FILE_NAME (JOVE_PERM_READ)
#define SYSCALL_PERM_INITRD_FILE_SIZE (JOVE_PERM_READ)
#define SYSCALL_PERM_INITRD_FILE_READ (JOVE_PERM_READ)

struct syscall_initrd_file_name_ret
{
    size_t len;
    char c_str[];
};

struct syscall_initrd_file_read
{
    size_t start_index;
    size_t read_size;
};

/**JOVE_OBJ_MESSAGE syscalls.
 * */

enum
{
    _SYSCALL_MESSAGE_NONE = 0,
};

/**JOVE_OBJ_VIRTTERM syscalls.*/

enum
{
    _SYSCALL_VTT_NONE = 0,
    SYSCALL_VTT_WRITE
};

#endif